예제 #1
0
        /// <summary>
        /// Create a new neural network
        /// with "inputs" inputs and size of "layers"
        /// layers of neurones.
        /// The layer i is made with layers_desc[i] neurones.
        /// The activation function of each neuron is set to default (Sigmoid with beta = 1).
        /// The lerning algorithm is set to default (Back Propagation).
        /// </summary>
        /// <param name="inputs">Number of inputs of the network</param>
        /// <param name="layers_desc">Number of neurons for each layer of the network</param>
        public NeuralNetwork(int inputs, int[] layers_desc)
        {
            if (layers_desc.Length < 1)
            {
                throw new Exception("PERCEPTRON : cannot build perceptron, it must have at least 1 layer of neurone");
            }
            if (inputs < 1)
            {
                throw new Exception("PERCEPTRON : cannot build perceptron, it must have at least 1 input");
            }
            la = new BackPropagationLearningAlgorithm(this);
            ni = inputs;
            ActivationFunction n_act = new SigmoidActivationFunction();

            layers    = new Layer[layers_desc.Length];
            layers[0] = new Layer(layers_desc[0], ni);
            for (int i = 1; i < layers_desc.Length; i++)
            {
                layers[i] = new Layer(layers_desc[i], layers_desc[i - 1], n_act);
            }
        }
예제 #2
0
		/// <summary>
		/// Create a new neural network
		/// with "inputs" inputs and size of "layers"
		/// layers of neurones.
		/// The layer i is made with layers_desc[i] neurones.
		/// The activation function of each neuron is set to default (Sigmoid with beta = 1).
		/// The lerning algorithm is set to default (Back Propagation).
		/// </summary>
		/// <param name="inputs">Number of inputs of the network</param>
		/// <param name="layers_desc">Number of neurons for each layer of the network</param>
		public NeuralNetwork(int inputs, int[] layers_desc)
		{
			if (layers_desc.Length<1)
				throw new Exception("PERCEPTRON : cannot build perceptron, it must have at least 1 layer of neurone");
			if (inputs<1)
				throw new Exception("PERCEPTRON : cannot build perceptron, it must have at least 1 input");
			la = new BackPropagationLearningAlgorithm(this);
			ni = inputs;
			ActivationFunction n_act = new SigmoidActivationFunction();
			layers = new Layer[layers_desc.Length];
			layers[0] = new Layer(layers_desc[0], ni);
			for(int i=1; i<layers_desc.Length; i++) 
				layers[i] = new Layer(layers_desc[i],layers_desc[i-1],n_act);
		}