예제 #1
0
 public NeuroItem(int num, Action <NeuroSignal> inputDataRequest, ActivationFooType activation)
 {
     ActivationMethod = activation;
     dataSum          = new NeuroSignal(num);
     dataOut          = new NeuroSignal(num);
     NeedInput        = inputDataRequest;
 }
예제 #2
0
        public NeuroLayer(int id, int countIn, int countOut, LayerRole role)
        {
            sync    = new object();
            Role    = role;
            LayerID = id;

            nucleus = new Dictionary <int, NeuroItem>();
            input   = new Dictionary <int, NeuroSignal>();
            output  = new Dictionary <int, NeuroSignal>();

            weights =
                Role == LayerRole.Input ? Matrix.Matrix.One(countIn, countOut) :
                Role == LayerRole.Output ? Matrix.Matrix.Half(countIn, countOut) :
                Matrix.Matrix.Half(countIn, countOut);

            ActivationFooType activation =
                Role == LayerRole.Input ? ActivationFooType.Identity : ActivationFooType.Sigmoid;

            #region -> TMP
            if (id == 2)
            {
                weights[0, 0] = 0.9; weights[0, 1] = 0.3; weights[0, 2] = 0.4;
                weights[1, 0] = 0.2; weights[1, 1] = 0.8; weights[1, 2] = 0.2;
                weights[2, 0] = 0.1; weights[2, 1] = 0.5; weights[2, 2] = 0.6;
            }
            if (id == 3)
            {
                weights[0, 0] = 0.3; weights[0, 1] = 0.7; weights[0, 2] = 0.5;
                weights[1, 0] = 0.6; weights[1, 1] = 0.5; weights[1, 2] = 0.2;
                weights[2, 0] = 0.8; weights[2, 1] = 0.1; weights[2, 2] = 0.9;
            }
            #endregion

            for (int num = 0; num < countIn; num++)
            {
                input.Add(num, new NeuroSignal(num));
            }

            for (int num = 0; num < countOut; num++)
            {
                NeuroItem ni =
                    new NeuroItem(num, TransmitInput, activation);

                nucleus.Add(num, ni);
                output.Add(num, new NeuroSignal(num));
            }
        }