Exemplo n.º 1
0
 private List<INeuron> CreateLayer(int layerSize, List<IInput> inputs)
 {
     var layerBias = new BiasInput(1.0d);
     var layer = new List<INeuron>();
     for (var i = 0; i < layerSize; i++)
     {
         var neuron = new Neuron(_activation);
         neuron.RegisterInput(layerBias, Util.GetRandomWeight());
         inputs.ForEach(input => neuron.RegisterInput(input, Util.GetRandomWeight()));
         layer.Add(neuron);
     }
     return layer;
 }
Exemplo n.º 2
0
 public List<INeuron> RestoreLayer(LayerModel layerModel, List<IInput> inputs)
 {
     var layerBias = new BiasInput(1.0d);
     var layer = new List<INeuron>();
     foreach (var model in layerModel.Neurons)
     {
         var neuron = new Neuron(_activation);
         neuron.RegisterInput(layerBias, model.InputWeights[0]);
         var inputWeights = model.InputWeights.Skip(1).ToArray();
         for (int j = 0; j < inputs.Count; j++)
         {
             neuron.RegisterInput(inputs[j], inputWeights[j]);
         }
         layer.Add(neuron);
     }
     return layer;
 }