Exemplo n.º 1
0
 protected Layer(int neuronsNumber, IActivation activationFunction, INetwork networkType, Bias bias = null) : base(neuronsNumber)
 {
     this.networkType = networkType;
     if (activationFunction is null)
     {
         this.activationFunction = new SigmoidFunction();
     }
     if (this is OutputLayer && networkType is RegressionNetwork)
     {
         this.activationFunction = new IdentityFunction();
     }
     else
     {
         this.activationFunction = activationFunction;
     }
     //if (!(activationFunction is null))
     //    this.activationFunction = activationFunction;
     for (int i = 0; i < neuronsNumber; i++)
     {
         this.neurons.Add(new Neuron(activationFunction, this.networkType));
     }
     if (bias == null)
     {
         return;
     }
     //neurons.Add(new InputNeuron(bias.Value));
     foreach (var neuron in this.neurons)
     {
         ((Neuron)neuron).AddPredecessors(new List <Tuple <INeuron, double> >()
         {
             new Tuple <INeuron, double>(new InputNeuron(bias.Value), bias.Wage)
         });
     }
 }
Exemplo n.º 2
0
 //readonly List<Tuple<INeuron, double>> incomingLayerTuple;
 public HiddenLayer(LayerBase incomingLayer, List <List <double> > initialWages, IActivation activationFunction, INetwork networkType, Bias bias = null)
     : base(initialWages.Count, activationFunction, networkType, bias)
 {
     //this.networkType = networkType;
     if (activationFunction is null)
     {
         this.activationFunction = new SigmoidFunction();
     }
     for (int i = 0; i < this.neurons.Count; i++)
     {
         var predecessors = new List <Tuple <INeuron, double> >();
         for (int j = 0; j < incomingLayer.Neurons.Count; j++)
         {
             predecessors.Add(new Tuple <INeuron, double>(incomingLayer.Neurons[j], initialWages[i][j]));
         }
         this.GetNeuron(i).AddPredecessors(predecessors);
     }
 }
Exemplo n.º 3
0
 public OutputLayer(LayerBase incomingLayer, List <List <double> > initialWages, IActivation activationFunction, INetwork networkType, Bias bias = null)
     : base(incomingLayer, initialWages, activationFunction, networkType, bias)
 {
     //if (activationFunction is null)
     this.activationFunction = activationFunction;
     this.networkType        = networkType;
 }