In the following example, we will train our CNN against the MNIST database of images.
To declare a function, use the following code:
private void MnistDemo()
{
Next, download the training and testing datasets with the following command:
var datasets = new DataSets();
Load 100 validation sets with the following command:
if (!datasets.Load(100))
{
return;
}
Now it's time to create the neural network using the Fluent API, as follows:
this._net = FluentNet<double>.Create(24, 24, 1)
.Conv(5, 5, 8).Stride(1).Pad(2)
.Relu()
.Pool(2, 2).Stride(2)
.Conv(5, 5, 16).Stride(1).Pad(2)
.Relu()
.Pool(3, 3).Stride(3)
.FullyConn(10)
.Softmax(10)
.Build();
Create the stochastic gradient descent trainer from the network with the following command:
this._trainer = new SgdTrainer<double>(this._net)
{
LearningRate = 0.01,
BatchSize = 20,
L2Decay = 0.001,
Momentum...