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 });
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset