public Network(int inputs, params int[] layerSizes) { var layers = new List<Neuron>(); layers.Add(new Neuron(inputs, false)); foreach (var size in layerSizes.Take(layerSizes.Length -1)) { var n = new Neuron(size); Neuron.Connect(layers.Last(), n); layers.Add(n); } var ln = new Neuron(layerSizes.Last(), false); Neuron.Connect(layers.Last(), ln); layers.Add(ln); foreach (var layer in layers) { layer.RandomizeWeights(); } Layers = layers.ToArray(); }
public Weight(double initValue, Neuron connectedNeuron) { Value = initValue; ConnectedNeuron = connectedNeuron; }
public static void Disconnect(Neuron from, Neuron to) { from.OutLinks = from.OutLinks.Where(l => l.To != to).ToArray(); to.InLinks = to.InLinks.Where(l => l.From != from).ToArray(); }
public static void Connect(Neuron from, Neuron to) { var l = new NeuronLink() { From = from, To = to, Weights = new float[from.Size, to.Size] }; from.OutLinks = from.OutLinks.Union(new[] { l }).ToArray(); to.InLinks = to.InLinks.Union(new[] { l }).ToArray(); }
public NeuronConnection(Neuron From, Neuron To, VariableArgumentValue value) { this.From = From; this.To = To; this.value = value; }
public void LinkTo(Neuron TargetNeuron, VariableArgumentValue Value) { var connection = new NeuronConnection(this, TargetNeuron, Value); Out.Add(connection); TargetNeuron.In.Add(connection); }