- Hands-On Neural Network Programming with C#
- Matt R. Cole
- 100字
- 2025-02-24 05:32:30
Example 3 – our final simple example
The following example does a simple calculation and displays the resultant computational graph. The code needed is as follows:
var cns = new ConvNetSharp<float>();
To create a graph, use the following code:
var x = cns.PlaceHolder("x");
var fun = 2.0f * x;
using (var session = new Session<float>())
{
Next, to compute the dCost/dW at every node of the graph, we use the following code:
session.Differentiate(fun);
Finally, to display the graph, input the following code:
var vm = new ViewModel<float>(x.Derivate);
var app = new Application();
app.Run(new GraphControl { DataContext = vm });
}