/// <summary> /// Creates connectivity between specified neuron and all neurons in specified layer /// </summary> /// <param name="fromNeuron"> /// neuron to connect </param> /// <param name="toLayer"> /// layer to connect to </param> public static void createConnection(Neuron fromNeuron, Layer toLayer) { foreach (Neuron toNeuron in toLayer.Neurons) { ConnectionFactory.createConnection(fromNeuron, toNeuron); } }
/// <summary> /// Creates forward connection pattern between specified layers /// </summary> /// <param name="fromLayer"> /// layer to connect </param> /// <param name="toLayer"> /// layer to connect to </param> public static void forwardConnect(Layer fromLayer, Layer toLayer) { for (int i = 0; i < fromLayer.NeuronsCount; i++) { Neuron fromNeuron = fromLayer.getNeuronAt(i); Neuron toNeuron = toLayer.getNeuronAt(i); createConnection(fromNeuron, toNeuron, 1); } }
/// <summary> /// Creates full connectivity between two specified layers with specified /// weight for all connections /// </summary> /// <param name="fromLayer"> /// output layer </param> /// <param name="toLayer"> /// input layer </param> /// <param name="weightVal"> /// connection weight value </param> public static void fullConnect(Layer fromLayer, Layer toLayer, double weightVal) { foreach (Neuron fromNeuron in fromLayer.Neurons) { foreach (Neuron toNeuron in toLayer.Neurons) { createConnection(fromNeuron, toNeuron, weightVal); } } }
/// <summary> /// Creates full connectivity between the two specified layers /// </summary> /// <param name="fromLayer"> /// layer to connect </param> /// <param name="toLayer"> /// layer to connect to </param> public static void fullConnect(Layer fromLayer, Layer toLayer, bool connectBiasNeuron) { foreach (Neuron fromNeuron in fromLayer.Neurons) { if (fromNeuron is BiasNeuron) { continue; } foreach (Neuron toNeuron in toLayer.Neurons) { createConnection(fromNeuron, toNeuron); } } }
/// <summary> /// Creates full connectivity within layer - each neuron with all other /// within the same layer with the specified weight and delay values for all /// conections. /// </summary> public static void fullConnect(Layer layer, double weightVal, int delay) { int neuronNum = layer.NeuronsCount; for (int i = 0; i < neuronNum; i++) { for (int j = 0; j < neuronNum; j++) { if (j == i) { continue; } Neuron from = layer.getNeuronAt(i); Neuron to = layer.getNeuronAt(j); createConnection(from, to, weightVal, delay); } // j } // i }