Training the network

There are two ways of training the network. One is to a minimum error value, the other is to a maximum error value. Both functions have defaults, although you may wish to make the threshold different for your training, as follows:

public NNManager TrainNetworkToMinimum()
{
var minError = GetDouble(" Minimum Error: ", 0.000000001, 1.0);
Console.WriteLine(" Training...");
_network.Train(_dataSets, minError);
Console.WriteLine(" **Training Complete**", Color.Green);
return this;
}

public NNManager TrainNetworkToMaximum()
{
varmaxEpoch = GetInput(" Max Epoch: ", 1, int.MaxValue);
if(!maxEpoch.HasValue)
{
return this;
}

Console.WriteLine(" Training...");
_network.Train(_dataSets, maxEpoch.Value);
Console.WriteLine(" **Training Complete**", Color.Green);
return this;
}

In both of the preceding function definitions, the neural network Train function is called to perform the actual training. This function in turn calls the forward and backward propagation functions for each dataset from within each iteration of the training loop, as follows:

public void Train(List<DataSet>dataSets, int numEpochs)
{
for (var i = 0; i<numEpochs; i++)
{
foreach (var dataSet in dataSets)
{
ForwardPropagate(dataSet.Values);
BackPropagate(dataSet.Targets);
}
}
}
..................Content has been hidden....................

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