internal void InitializeAlgo(BufferAllocator allocator, LearningRule rule, ConnectedLayer[] connectedLayers, CPUNNInitParameters initPars) { Contract.Requires(rule != null); Contract.Requires(connectedLayers != null); Contract.Requires(connectedLayers.Length > 0); Contract.Requires(initPars != null); Rule = rule; ConnectedLayers = connectedLayers; RunParallel = initPars.RunParallel; Ininitalize(allocator); }
internal void Initialize( LearningRule rule, ValueSpace<double> valueSpace, InputValueIndexes[] inputValueIndexes, OutputValueIndexes[] outputValueIndexes) { Contract.Requires(rule != null); Contract.Requires(valueSpace != null); Contract.Requires(inputValueIndexes != null); Contract.Requires(outputValueIndexes != null); Contract.Requires(inputValueIndexes.Length == outputValueIndexes.Length); Rule = rule; ValueSpace = valueSpace; this.inputValueIndexes = inputValueIndexes; this.outputValueIndexes = outputValueIndexes; ValueCount = inputValueIndexes.Length; InitializeNewRun(true); }
/// <summary> /// Runs this sample /// </summary> public virtual void run() { // create training set (logical XOR function) DataSet trainingSet = new DataSet(2, 1); trainingSet.addRow(new DataSetRow(new double[] { 0, 0 }, new double[] { 0 })); trainingSet.addRow(new DataSetRow(new double[] { 0, 1 }, new double[] { 1 })); trainingSet.addRow(new DataSetRow(new double[] { 1, 0 }, new double[] { 1 })); trainingSet.addRow(new DataSetRow(new double[] { 1, 1 }, new double[] { 0 })); // create multi layer perceptron MultiLayerPerceptron myMlPerceptron = new MultiLayerPerceptron(TransferFunctionType.SIGMOID, 2, 3, 1); myMlPerceptron.LearningRule = new BackPropagation(); // enable batch if using MomentumBackpropagation // if( myMlPerceptron.getLearningRule() instanceof MomentumBackpropagation ) // ((MomentumBackpropagation)myMlPerceptron.getLearningRule()).setBatchMode(false); LearningRule learningRule = myMlPerceptron.LearningRule; learningRule.addListener(this); // learn the training set Console.WriteLine("Training neural network..."); myMlPerceptron.learn(trainingSet); // test perceptron Console.WriteLine("Testing trained neural network"); testNeuralNetwork(myMlPerceptron, trainingSet); // save trained neural network myMlPerceptron.save("myMlPerceptron.nnet"); // load saved neural network NeuralNetwork loadedMlPerceptron = NeuralNetwork.createFromFile("myMlPerceptron.nnet"); // test loaded neural network Console.WriteLine("Testing loaded neural network"); testNeuralNetwork(loadedMlPerceptron, trainingSet); }
public LearningEvent(LearningRule source, LearningEvent.Type eventType) : base(source) { this.eventType = eventType; }
private LearningAlgorithm CreateAlgorithmForRule(LearningRule rule) { LearningAlgorithm algo = null; if (rule is NoisedWeightInitializationRule) { algo = new NoisedWeightInitializationAlgorithm(); } else if (rule is SignChangesRule) { algo = new SignChangesAlgorithm(); } else if (rule is GradientDescentRule) { algo = new GradientDescentAlgorithm(); } else if (rule is AlopexBRule) { algo = new AlopexBAlgorithm(); } else if (rule is GaussianHistoryRule) { algo = new GaussianHistoryAlgorithm(); } else if (rule is QSARule) { algo = new QSAAlgorithm(); } if (algo != null) return algo; throw new InvalidOperationException("Cannot build CPU Neural Network, because '" + rule.GetType().FullName + "' learning rule type is unknown."); }
/// <summary> /// Learn the specified training set, using specified learning rule /// </summary> /// <param name="trainingSet"> set of training elements to learn </param> /// <param name="learningRule"> instance of learning rule to use for learning </param> public virtual void learn(DataSet trainingSet, LearningRule learningRule) { LearningRule = learningRule; learningRule.learn(trainingSet); }
internal void InitializeAlgo(BufferAllocator allocator, LearningRule learningRule, ConnectedLayer[] connectedLayer) { throw new NotImplementedException(); }