GibTreaty

NeuralLayer.cs

Apr 4th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. namespace YounGenTech.NeuralNetwork {
  4.     [System.Serializable]
  5.     public class Layer {
  6.  
  7.         [SerializeField]
  8.         Neuron[] _neurons;
  9.  
  10.         public int Count {
  11.             get { return _neurons.Length; }
  12.         }
  13.         public float[] LastOutput { get; protected set; }
  14.  
  15.         public Neuron this[int index] {
  16.             get { return _neurons[index]; }
  17.         }
  18.  
  19.  
  20.         public Layer(params Neuron[] neurons) {
  21.             SetNeurons(neurons);
  22.         }
  23.  
  24.  
  25.         public float[] Output(float[] data) {
  26.             float[] newData = new float[Count];
  27.  
  28.             for(int i = 0; i < Count; i++)
  29.                 newData[i] = _neurons[i].Output(data);
  30.  
  31.             LastOutput = newData;
  32.  
  33.             return newData;
  34.         }
  35.  
  36.         public void SetNeurons(params Neuron[] neurons) {
  37.             _neurons = neurons;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment