/** * Prints network output for the each element from the specified training set. * @param neuralNet neural network * @param trainingSet training set */ public static void TestNeuralNetwork(NeuralNetwork neuralNet, TrainingSet trainingSet) { foreach (TrainingElement trainingElement in trainingSet.TrainingElements) { neuralNet.SetInput(trainingElement.Input); neuralNet.Calculate(); double[] networkOutput = neuralNet.Output; Console.Write("Input: " + trainingElement.Input.ArrayString()); Console.WriteLine(" Output: " + networkOutput.ArrayString()); } }
/// <summary> /// Creates new PerceptronLearning learning for the specified neural network /// </summary> /// <param name="neuralNetwork"></param> public PerceptronLearning(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates new instance of InstarLearning algorithm for the specified /// neural network. /// </summary> /// <param name="neuralNetwork">neural network to train</param> public InstarLearning(NeuralNetwork neuralNetwork) : base(neuralNetwork) { this.LearningRate = 0.1; }
/// <summary> /// Creates new SigmoidDeltaRule for the specified neural network /// </summary> /// <param name="neuralNetwork">neural network to train</param> public SigmoidDeltaRule(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Sets default input and output neurons for network (first layer as input, /// last as output) /// </summary> /// <param name="nnet"></param> public static void SetDefaultIO(NeuralNetwork nnet) { IList<Neuron> inputNeurons = new List<Neuron>(); Layer firstLayer = (Layer)nnet.Layers[0]; foreach (Neuron neuron in firstLayer.Neurons) { if (!(neuron is BiasNeuron)) { // dont set input to bias neurons inputNeurons.Add(neuron); } } IList<Neuron> outputNeurons = ((Layer)nnet.Layers[nnet.Layers.Count - 1]).Neurons; nnet.InputNeurons = inputNeurons; nnet.OutputNeurons = outputNeurons; }
/** * Predict sunspots. * @param network Neural network to use. */ public void Predict(NeuralNetwork network) { Console.WriteLine("Year\tActual\tPredict\tClosed Loop Predict"); for (int year = EVALUATE_START; year < EVALUATE_END; year++) { // calculate based on actual data double[] input = new double[WINDOW_SIZE]; for (int i = 0; i < input.Length; i++) { input[i] = this.normalizedSunspots[(year - WINDOW_SIZE) + i]; } network.SetInput(input); network.Calculate(); double[] output = network.Output; double prediction = output[0]; this.closedLoopSunspots[year] = prediction; // calculate "closed loop", based on predicted data for (int i = 0; i < input.Length; i++) { input[i] = this.closedLoopSunspots[(year - WINDOW_SIZE) + i]; } network.SetInput(input); network.Calculate(); output = network.Output; double closedLoopPrediction = output[0]; // display Console.WriteLine((STARTING_YEAR + year) + "\t" + this.normalizedSunspots[year] + "\t" + prediction + "\t" + closedLoopPrediction); } }
public DynamicBackPropagation(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates new instance of CompetitiveLearning for the specified neural network /// </summary> /// <param name="neuralNetwork"></param> public CompetitiveLearning(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates new HopfieldLearning for the specified neural network /// </summary> /// <param name="neuralNetwork"></param> public HopfieldLearning(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates new instance of SupervisedHebbianLearning algorithm for the specified /// neural network. /// </summary> /// <param name="neuralNetwork">neural network to train</param> public SupervisedHebbianLearning(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates new instance of BinaryHebbianLearning for the specified neural network /// </summary> /// <param name="neuralNetwork"></param> public BinaryHebbianLearning(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates new LMS learning rule for specified neural network /// </summary> /// <param name="neuralNetwork">neural network to train</param> public LMS(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates an instance of OjaLearning algorithm for the specified /// neural network /// </summary> /// <param name="neuralNetwork">neural network to train</param> public OjaLearning(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates new BinaryDeltaRule learning for the specified neural network /// </summary> /// <param name="neuralNetwork"></param> public BinaryDeltaRule(NeuralNetwork neuralNetwork) : base(neuralNetwork) { }
/// <summary> /// Creates an instance of UnsupervisedHebbianLearning algorithm for the specified /// neural network /// </summary> /// <param name="neuralNetwork">neural network to train</param> public UnsupervisedHebbianLearning(NeuralNetwork neuralNetwork) : base(neuralNetwork) { this.LearningRate = 0.1; }
/// <summary> /// Creates new instance of MomentumBackpropagation learning for the specified neural network /// </summary> /// <param name="neuralNetwork">neural network to train</param> public MomentumBackpropagation(NeuralNetwork neuralNetwork) : base(neuralNetwork) { Momentum = 0.25d; }