本文整理汇总了C#中Encog.Neural.Networks.BasicNetwork.AddLayer方法的典型用法代码示例。如果您正苦于以下问题:C# BasicNetwork.AddLayer方法的具体用法?C# BasicNetwork.AddLayer怎么用?C# BasicNetwork.AddLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encog.Neural.Networks.BasicNetwork
的用法示例。
在下文中一共展示了BasicNetwork.AddLayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Preprocessing_Completed
private void Preprocessing_Completed(object sender, RunWorkerCompletedEventArgs e)
{
worker.ReportProgress(0, "Creating Network...");
BasicNetwork Network = new BasicNetwork();
Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, DataContainer.NeuralNetwork.Data.InputSize));
Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 50));
Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, DataContainer.NeuralNetwork.Data.IdealSize));
Network.Structure.FinalizeStructure();
Network.Reset();
DataContainer.NeuralNetwork.Network = Network;
ResilientPropagation training = new ResilientPropagation(DataContainer.NeuralNetwork.Network, DataContainer.NeuralNetwork.Data);
worker.ReportProgress(0, "Running Training: Epoch 0");
for(int i = 0; i < 200; i++)
{
training.Iteration();
worker.ReportProgress(0, "Running Training: Epoch " + (i+1).ToString() + " Current Training Error : " + training.Error.ToString());
if(worker.CancellationPending == true)
{
completed = true;
return;
}
}
completed = true;
}
示例2: Run
public override void Run()
{
testNetwork = new BasicNetwork();
testNetwork.AddLayer(new BasicLayer(null, true, 2));
testNetwork.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 4));
testNetwork.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
testNetwork.Structure.FinalizeStructure();
testNetwork.Reset();
// create training data
IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);
// train the neural network
IMLTrain train = new Backpropagation(testNetwork, trainingSet);
//IMLTrain train = new ResilientPropagation(testNetwork, trainingSet); //Encog manual says it is the best general one
int epoch = 1;
do
{
train.Iteration();
Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
epoch++;
} while (train.Error > 0.0001);
// test the neural network
Console.WriteLine(@"Neural Network Results:");
foreach (IMLDataPair pair in trainingSet)
{
IMLData output = testNetwork.Compute(pair.Input);
Console.WriteLine(pair.Input[0] + @"," + pair.Input[1]
+ @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
}
}
示例3: Execute
/// <summary>
/// Program entry point.
/// </summary>
/// <param name="app">Holds arguments and other info.</param>
public void Execute(IExampleInterface app)
{
// create a neural network, without using a factory
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, true, 2));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
network.Structure.FinalizeStructure();
network.Reset();
// create training data
IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);
// train the neural network
IMLTrain train = new ResilientPropagation(network, trainingSet);
int epoch = 1;
do
{
train.Iteration();
Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
epoch++;
} while (train.Error > 0.01);
// test the neural network
Console.WriteLine(@"Neural Network Results:");
foreach (IMLDataPair pair in trainingSet)
{
IMLData output = network.Compute(pair.Input);
Console.WriteLine(pair.Input[0] + @"," + pair.Input[1]
+ @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
}
}
示例4: Main
static void Main(string[] args)
{
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, true, 2));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
network.Structure.FinalizeStructure();
network.Reset();
var trainingSet = new BasicMLDataSet(XORInput, XORIdeal);
var train = new ResilientPropagation(network, trainingSet);
var epoch = 1;
do
{
train.Iteration();
} while (train.Error > 0.01);
train.FinishTraining();
foreach (var pair in trainingSet)
{
var output = network.Compute(pair.Input);
Console.WriteLine(pair.Input[0] + @", " + pair.Input[1] + @" , actual=" + output[0] + @", ideal=" + pair.Ideal[0]);
}
EncogFramework.Instance.Shutdown();
Console.ReadLine();
}
示例5: TestSingleOutput
public void TestSingleOutput()
{
BasicNetwork network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, true, 2));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 2));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
network.Structure.FinalizeStructure();
(new ConsistentRandomizer(-1, 1)).Randomize(network);
IMLDataSet trainingData = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal);
HessianFD testFD = new HessianFD();
testFD.Init(network, trainingData);
testFD.Compute();
HessianCR testCR = new HessianCR();
testCR.Init(network, trainingData);
testCR.Compute();
//dump(testFD, "FD");
//dump(testCR, "CR");
Assert.IsTrue(testCR.HessianMatrix.equals(testFD.HessianMatrix, 4));
}
示例6: BenchmarkEncog
public static long BenchmarkEncog(double[][] input, double[][] output)
{
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, true,
input[0].Length));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true,
HIDDEN_COUNT));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), false,
output[0].Length));
network.Structure.FinalizeStructure();
network.Reset(23); // constant seed for repeatable testing
IMLDataSet trainingSet = new BasicMLDataSet(input, output);
// train the neural network
IMLTrain train = new Backpropagation(network, trainingSet, 0.7, 0.7);
var sw = new Stopwatch();
sw.Start();
// run epoch of learning procedure
for (int i = 0; i < ITERATIONS; i++)
{
train.Iteration();
}
sw.Stop();
return sw.ElapsedMilliseconds;
}
示例7: Main
static void Main(string[] args)
{
//create a neural network withtout using a factory
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, true, 2));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 2));
network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
network.Structure.FinalizeStructure();
network.Reset();
IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);
IMLTrain train = new ResilientPropagation(network, trainingSet);
int epoch = 1;
do
{
train.Iteration();
Console.WriteLine($"Epoch #{epoch} Error: {train.Error}");
epoch++;
} while (train.Error > 0.01);
train.FinishTraining();
Console.WriteLine("Neural Network Results:");
foreach (IMLDataPair iPair in trainingSet)
{
IMLData output = network.Compute(iPair.Input);
Console.WriteLine($"{iPair.Input[0]}, {iPair.Input[0]}, actual={output[0]}, ideal={iPair.Ideal[0]}");
}
EncogFramework.Instance.Shutdown();
Console.ReadKey();
}
示例8: generateNetwork
public BasicNetwork generateNetwork()
{
BasicNetwork network = new BasicNetwork();
network.AddLayer(new BasicLayer(MultiThreadBenchmark.INPUT_COUNT));
network.AddLayer(new BasicLayer(MultiThreadBenchmark.HIDDEN_COUNT));
network.AddLayer(new BasicLayer(MultiThreadBenchmark.OUTPUT_COUNT));
network.Structure.FinalizeStructure();
network.Reset();
return network;
}
示例9: Create
public void Create(int inputnodes,int hiddennodes)
{
network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, true, inputnodes));
network.AddLayer(new BasicLayer(new ActivationTANH(), true, hiddennodes));
network.AddLayer(new BasicLayer(new ActivationLinear(), false, 1));
network.Structure.FinalizeStructure();
network.Reset();
this.hiddennodes = hiddennodes;
}
示例10: generateNetwork
public BasicNetwork generateNetwork()
{
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(INPUT_COUNT));
network.AddLayer(new BasicLayer(HIDDEN_COUNT));
network.AddLayer(new BasicLayer(OUTPUT_COUNT));
network.Structure.FinalizeStructure();
network.Reset();
return network;
}
示例11: CreateThreeLayerNet
public static BasicNetwork CreateThreeLayerNet()
{
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(2));
network.AddLayer(new BasicLayer(3));
network.AddLayer(new BasicLayer(1));
network.Structure.FinalizeStructure();
network.Reset();
return network;
}
示例12: CreateNetwork
/// <summary>
/// Metodo responsavel por criar a rede neural
/// </summary>
/// <param name="source">FileInfo com o path do network</param>
private static void CreateNetwork(FileInfo source)
{
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(new ActivationLinear(), true, 4));
network.AddLayer(new BasicLayer(new ActivationTANH(), true, 6));
network.AddLayer(new BasicLayer(new ActivationTANH(), false, 2));
network.Structure.FinalizeStructure();
network.Reset();
EncogDirectoryPersistence.SaveObject(source, (BasicNetwork)network);
}
示例13: createElliott
public static BasicNetwork createElliott()
{
BasicNetwork network = new BasicNetwork();
network.AddLayer(new BasicLayer(null, true, INPUT_OUTPUT));
network.AddLayer(new BasicLayer(new ActivationElliottSymmetric(), true, HIDDEN));
network.AddLayer(new BasicLayer(new ActivationElliottSymmetric(), false, INPUT_OUTPUT));
network.Structure.FinalizeStructure();
network.Reset();
return network;
}
示例14: ConstructNetwork
private BasicNetwork ConstructNetwork()
{
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(new ActivationTANH(), true, VanDerWaerdenGameRules.VanDerWaerdenNumber(this.NColors, this.ProgressionLength) - 1));
network.AddLayer(new BasicLayer(new ActivationTANH(), true, VanDerWaerdenGameRules.VanDerWaerdenNumber(this.NColors, this.ProgressionLength)));
network.AddLayer(new BasicLayer(new ActivationTANH(), true, 1));
network.Structure.FinalizeStructure();
return network;
Debug.Print("Created new Network with parameters nColors = {0} and progression length = {1}.", NColors, ProgressionLength);
}
示例15: CreateNetwork
public static void CreateNetwork(FileOps fileOps)
{
var network = new BasicNetwork();
network.AddLayer(new BasicLayer(new ActivationLinear(),true,4));
network.AddLayer(new BasicLayer(new ActivationTANH(), true, 6));
network.AddLayer(new BasicLayer(new ActivationTANH(), true, 2));
network.Structure.FinalizeStructure();
network.Reset();
EncogDirectoryPersistence.SaveObject(fileOps.TrainedNeuralNetworkFile, network);
}