Beispiel #1
0
        /// <summary>
        /// Runs this sample
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void main(String[] args) throws java.io.FileNotFoundException, java.io.IOException
        public static void Main(string[] args)
        {
            // create neural network
            MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(2, 3, 1);

            // use file provided in org.neuroph.sample.data package
            string inputFileName = typeof(FileIOSample).getResource("data/xor_data.txt").File;
            // create file input adapter using specifed file
            FileInputAdapter fileIn = new FileInputAdapter(inputFileName);
            // create file output  adapter using specified file name
            FileOutputAdapter fileOut = new FileOutputAdapter("some_output_file.txt");


            double[] input;             // input buffer used for reading network input from file
            // read network input using input adapter
            while ((input = fileIn.readInput()) != null)
            {
                // feed neywork with input
                neuralNet.Input = input;
                // calculate network ...
                neuralNet.calculate();
                // .. and get network output
                double[] output = neuralNet.Output;
                // write network output using output adapter
                fileOut.writeOutput(output);
            }

            // close input and output files
            fileIn.close();
            fileOut.close();

            // Also note that shorter way for this is using org.neuroph.util.io.IOHelper class
        }
Beispiel #2
0
        public MatrixMultiLayerPerceptron(MultiLayerPerceptron sourceNetwork)
        {
            this.sourceNetwork = sourceNetwork;
            // copy layers, input and output neurons

            createMatrixLayers();
            this.LearningRule = new MatrixMomentumBackpropagation();
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            DataSet irisDataSet = loadDataSet();

            MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(4, 15, 3);

            configureLearningRule(neuralNet);
            neuralNet.learn(irisDataSet);

            Evaluation.runFullEvaluation(neuralNet, irisDataSet);
        }
        public static void Main(string[] args)
        {
            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 }));

            MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(TransferFunctionType.TANH, 2, 3, 1);

            neuralNet.learn(trainingSet);

            Evaluation.runFullEvaluation(neuralNet, trainingSet);
        }
Beispiel #5
0
 private static void configureLearningRule(MultiLayerPerceptron neuralNet)
 {
     neuralNet.LearningRule.LearningRate  = 0.02;
     neuralNet.LearningRule.MaxError      = 0.01;
     neuralNet.LearningRule.ErrorFunction = new MeanSquaredError();
 }