protected InnovationNumber GetFreeNeuronInnovNb() { if (!Neurons.Any()) { return(0); } else { return(Neurons.Keys.Max(x => x.value) + 1); } }
/// <summary> /// Creates a layer with the given neurons. /// </summary> public Layer([NotNull] params Neuron[] neurons) { Neurons = neurons; if (Neurons.Length < 1) { throw new ArgumentException("Layer must contain at least one neuron"); } if (Neurons.Any(neuron => neuron == null)) { throw new NullReferenceException("Neuron may not be null"); } var degree = Neurons[0].Degree; if (Neurons.Any(neuron => neuron.Degree != degree)) { throw new ArgumentException("Inconsistent neuron degrees"); } InputDimension = degree; }
public void Update(IReadOnlyList <float> inputs) { if (inputs == null) { throw new ArgumentNullException("inputs"); } if (inputs.Count != NumInputs) { throw new InvalidOperationException(string.Format( "Expected {0} inputs, got {1}", NumInputs, inputs.Count)); } if (!Neurons.Any()) { throw new InvalidOperationException("No neurons in the layer"); } inputs.CopyAllTo(m_inputs); for (var i = 0; i < Neurons.Count; i++) { Neurons[i].Update(inputs); m_outputs[i] = Neurons[i].Output; } }