HiddenNeuron[] denseHiddenLayer(int numberOfNeurons, int numberOfInputOfEachNeuron, double learningRate = 1, string layerName = "hiddenNeuron") { HiddenNeuron[] on = new HiddenNeuron[numberOfNeurons]; for (int c = 0; c < numberOfNeurons; c++) { on [c] = new HiddenNeuron(numberOfInputOfEachNeuron, layerName + c.ToString(), learningRate); } return(on); }
public HiddenLayer(int size, Network n) : base(size, n) { HiddenNeuron[] InputNeurons = new HiddenNeuron[size]; for (int i = 0; i < size; i++) { InputNeurons[i] = new HiddenNeuron(this); InputNeurons[i].name = "HiddenNeuron " + i; } this.neurons = InputNeurons; }
ParameterList <double> getInputList(HiddenNeuron[] hiddenLayer, HiddenNeuron nextNeuron) { ParameterList <double> list = new ParameterList <double> (hiddenLayer.Length); for (int c = 0; c < list.Length; c++) { list [c] = hiddenLayer [c].Output(c, nextNeuron); } return(list); }
private void CreateNeurons(ushort[] layerSizes, ITransferFunction[] transferFunctions) { if (layerSizes.Length != transferFunctions.Length) { throw new ArgumentException("Cannot make a network with these parameters."); } if (transferFunctions[0] != null) { throw new ArgumentException("Input layer transfer function must be null."); } Neurons = new Neuron[layerSizes.Length][]; for (byte l = 0; l < layerSizes.Length; l++) { // creates neurons in the input layer if (l == 0) { Neurons[l] = new InputNeuron[layerSizes[l]]; for (ushort i = 0; i < layerSizes[l]; i++) { Neurons[l][i] = new InputNeuron(transferFunctions[l]); } } // creates neurons in the hidden layer(s) else if (l < layerSizes.Length - 1) { Neurons[l] = new HiddenNeuron[layerSizes[l]]; for (ushort i = 0; i < layerSizes[l]; i++) { Neurons[l][i] = new HiddenNeuron(transferFunctions[l]); } } // creates neurons in the output layer else { Neurons[l] = new OutputNeuron[layerSizes[l]]; for (ushort i = 0; i < layerSizes[l]; i++) { Neurons[l][i] = new OutputNeuron(transferFunctions[l]); } } } }
private void CreateHiddenLayers() { for (int j = 0; j < Topology.HiddenLayersCount; j++) { var hiddenNeuron = new Neuron[Topology.HiddenLayers[j]]; var preLastLayer = Layers[j]; for (int i = 0; i < Topology.HiddenLayers[j]; i++) { var neuron = new HiddenNeuron(preLastLayer.NeuronsCountInLayer); hiddenNeuron[i] = neuron; Thread.Sleep(10); } var hiddenLayer = new Layer(hiddenNeuron); Layers[j + 1] = hiddenLayer; } }
internal virtual IList <ICollection <IHiddenNeuron> > BuildHiddenLayers(IEnumerable <INeuron> previousLayer, HiddenLayerSettings settings, ushort recurrentInputs = 0) { var tempLayer = new List <ICollection <IHiddenNeuron> >(settings.LayersCount); IEnumerable <INeuron> prevLayer = previousLayer; for (int i = 0; i < settings.LayersCount; i++) { var tempHidden = new List <IHiddenNeuron>(settings.NeuronsCount); for (int j = 0; j < settings.NeuronsCount; j++) { var neuron = new HiddenNeuron(settings.FunctionType, recurrentInputs); tempHidden.Add(neuron); foreach (var inNeuron in prevLayer) { ConnectAxon(inNeuron, neuron, settings.NeuronsCount); } } if (settings.HasBiasNeuron) { var biasNeuron = new BiasNeuron(); tempHidden.Add(biasNeuron); foreach (var inNeuron in previousLayer) { ConnectAxon(inNeuron, biasNeuron, settings.NeuronsCount); } } prevLayer = tempHidden; tempLayer.Add(tempHidden); } return(tempLayer); }