本文整理汇总了C#中Network.BindTraining方法的典型用法代码示例。如果您正苦于以下问题:C# Network.BindTraining方法的具体用法?C# Network.BindTraining怎么用?C# Network.BindTraining使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network.BindTraining方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildNetwork
public void BuildNetwork()
{
_network = new Network(_node);
_network.AddLayer(4); //Hidden layer with 2 neurons
_network.AddLayer(1); //Output layer with 1 neuron
_network.BindInputLayer(_input); //Bind Input Data
_network.BindTraining(_desired); //Bind desired output data
_network.AutoLinkFeedforward(); //Create synapses between the layers for typical feedforward networks.
}
示例2: RunDemo
public void RunDemo()
{
Console.WriteLine("### BASIC BOUND DEMO ###");
//Prepare you're input and training data
//to bind to the network
double[] input = new double[] {-5d,5d,-5d};
double[] training = new double[] {-1,1};
//Initialize the network manager.
//This constructor also creates the first
//network layer (Inputlayer).
Network network = new Network();
//Bind your input array (to the already
//existing input layer)
network.BindInputLayer(input);
//Add the hidden layer with 4 neurons.
network.AddLayer(4);
//Add the output layer with 2 neurons.
network.AddLayer(2);
//bind your training array to the output layer.
//Always do this AFTER creating the layers.
network.BindTraining(training);
//Connect the neurons together using synapses.
//This is the easiest way to do it; I'll discuss
//other ways in more detail in another demo.
network.AutoLinkFeedforward();
//Propagate the network using the bound input data.
//Internally, this is a two round process, to
//correctly handle feedbacks
network.CalculateFeedforward();
//Collect the network output and print it.
App.PrintArray(network.CollectOutput());
//Train the current pattern using Backpropagation (one step)!
network.TrainCurrentPattern(false,true);
//Print the output; the difference to (-1,1) should be
//smaller this time!
App.PrintArray(network.CollectOutput());
//Same one more time:
network.TrainCurrentPattern(false,true);
App.PrintArray(network.CollectOutput());
//Train another pattern:
Console.WriteLine("# new pattern:");
input[0] = 5d;
input[1] = -5d;
training[0] = 1;
//calculate ...
network.CalculateFeedforward();
App.PrintArray(network.CollectOutput());
//... and train it one time
network.TrainCurrentPattern(false,true);
App.PrintArray(network.CollectOutput());
//what about the old pattern now?
Console.WriteLine("# the old pattern again:");
input[0] = -5d;
input[1] = 5d;
training[0] = -1;
network.CalculateFeedforward();
App.PrintArray(network.CollectOutput());
Console.WriteLine("=== COMPLETE ===");
Console.WriteLine();
}