public NeuralNetwork(params int[] units)
        {
            learning_rate = 0.03f;
            momentum_rate = 0.3f;
            error_limit   = 0.005f;
            ignore_error  = false;
            infinite_loop = false;
            max_circle    = int.MaxValue;
            circle        = 0;
            score         = 0f;
            fitness       = 0f;
            id            = 0;

            layers = new Layer[units.Length];

            for (int i = 0; i < layers.Length; i++)
            {
                PerceptronType.Type type = PerceptronType.Type.hidden;
                if (i == 0)
                {
                    type = PerceptronType.Type.input;
                }
                else if (i == layers.Length - 1)
                {
                    type = PerceptronType.Type.output;
                }
                layers[i] = new Layer(units[i], (i != 0), ActivationType.Type.sigmoid, type);
            }

            input_layer   = this.layers[0];
            hidden_layers = new Layer[layers.Length - 2];
            for (int i = 0; i < hidden_layers.Length; i++)
            {
                hidden_layers[i] = this.layers[i + 1];
            }
            output_layer = this.layers[this.layers.Length - 1];

            for (int i = 0; i < layers.Length - 1; i++)
            {
                Layer.Connect(this.layers[i], this.layers[i + 1]);
            }
        }
Exemplo n.º 2
0
 public Layer(int len, bool bias_enable, ActivationType.Type activation_type, PerceptronType.Type perceptron_type)
 {
     type = perceptron_type;
     for (int i = 0; i < len; i++)
     {
         perceptrons.Add(new Perceptron()
         {
             activation_type = activation_type,
             type            = type,
             tag             = "untitled",
             current_layer   = this
         });
     }
     if (bias_enable)
     {
         bias = new Perceptron()
         {
             type          = PerceptronType.Type.bias,
             tag           = "bias",
             state         = 1f,
             current_layer = this
         };
     }
 }