public override Neuron NameCopy() { InputNeuron clone = new InputNeuron(); clone.SetName(GetName()); return(clone); }
public void AddInputNeuronAndMesh(InputNeuron neuron) { InputNeurons.Add(neuron); foreach (WorkingNeuron wn in FirstHiddenLayer) { wn.AddNeuronConnection(new Connection(neuron, 0)); } }
public void AddInputNeuronAndMesh(InputNeuron neuron) { inputNeurons.Add(neuron); foreach (WorkingNeuron wn in hiddenNeurons) { wn.AddNeuronConnection(new Connection(neuron, 0)); } }
public void Deserialize(BinaryReader reader) { fullMeshGenerated = reader.ReadBoolean(); int inputCount = reader.ReadInt32(); for (int currentIndex = 0; currentIndex < inputCount; currentIndex++) { InputNeuron newNeuron = new InputNeuron(); newNeuron.Deserialize(reader); inputNeurons.Add(newNeuron); } int hiddenCount = reader.ReadInt32(); for (int currentIndex = 0; currentIndex < hiddenCount; currentIndex++) { WorkingNeuron newNeuron = new WorkingNeuron(); newNeuron.Deserialize(reader); hiddenNeurons.Add(newNeuron); int connectionCount = reader.ReadInt32(); for (int connectionIndex = 0; connectionIndex < connectionCount; connectionIndex++) { // Todo get rid of this covariance cast Connection connection = Connection.Deserialize(reader, inputNeurons.Cast <Neuron>()); newNeuron.AddNeuronConnection(connection); } } int outputCount = reader.ReadInt32(); for (int currentIndex = 0; currentIndex < outputCount; currentIndex++) { WorkingNeuron newNeuron = new WorkingNeuron(); newNeuron.Deserialize(reader); outputNeurons.Add(newNeuron); int connectionCount = reader.ReadInt32(); for (int connectionIndex = 0; connectionIndex < connectionCount; connectionIndex++) { // Todo get rid of this covariance cast Connection connection = Connection.Deserialize(reader, hiddenNeurons.Cast <Neuron>()); newNeuron.AddNeuronConnection(connection); } } Invalidate(); }
public void RemoveInputNeuron(InputNeuron neuron) { InputNeurons.Remove(neuron); foreach (WorkingNeuron wn in neurons[1]) { List <Connection> connectionsToRemove = new List <Connection>(); foreach (Connection c in wn.GetConnections()) { if (c.entryNeuron == neuron) { connectionsToRemove.Add(c); } } foreach (Connection c in connectionsToRemove) { wn.GetConnections().Remove(c); } } }
public static void Test() { Console.WriteLine("Begin NN Test!"); NeuronalNetwork nn = new NeuronalNetwork(); InputNeuron in1 = new InputNeuron(); InputNeuron in2 = new InputNeuron(); InputNeuron in3 = new InputNeuron(); WorkingNeuron out1 = new WorkingNeuron(0); WorkingNeuron out2 = new WorkingNeuron(0); WorkingNeuron out3 = new WorkingNeuron(0); nn.AddInputNeuron(in1); nn.AddInputNeuron(in2); nn.AddInputNeuron(in3); nn.GenerateHiddenNeurons(3, 1); nn.AddOutputNeuron(out1); nn.AddOutputNeuron(out2); nn.AddOutputNeuron(out3); nn.GenerateFullMesh(); nn.RandomizeAllWeights(); NeuronalNetwork nn2 = nn.CloneFullMesh(); for (int i = 0; i < 3; i++) { Debug.Assert(nn2.GetOutputNeuronFromIndex(i).GetValue() == nn.GetOutputNeuronFromIndex(i).GetValue()); } Console.WriteLine("NN Test success! <(^.^)>"); }
public void AddInputNeuron(InputNeuron neuron) { inputNeurons.Add(neuron); }