void Create()
 {
     network = new NeuralNetwork.NeuralNetwork(input.Length, layers);
     if (genetic)
         learning = new GeneticLearningAlgorithm(network);
     else
         learning = new BackPropagationLearningAlgorithm(network);
     network.randomizeAll();
     network.LearningAlg = learning;
 }
 void Create()
 {
     network = new NeuralNetwork.NeuralNetwork(input.Length, layers);
     if (genetic)
     {
         learning = new GeneticLearningAlgorithm(network);
     }
     else
     {
         learning = new BackPropagationLearningAlgorithm(network);
     }
     network.randomizeAll();
     network.LearningAlg = learning;
 }
Beispiel #3
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 n_act.
 /// 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>
 /// <param name="n_act">Activation function for each neuron in the network</param>
 public NeuralNetwork(int inputs, int[] layers_desc, ActivationFunction n_act)
 {
     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;
     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);
     }
 }
		/// <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);
		}