Пример #1
0
        /// <summary>
        /// Create a simple feedforward neural network.
        /// </summary>
        /// <param name="input">The number of input neurons.</param>
        /// <param name="hidden1">The number of hidden layer 1 neurons.</param>
        /// <param name="hidden2">The number of hidden layer 2 neurons.</param>
        /// <param name="output">The number of output neurons.</param>
        /// <param name="tanh">True to use hyperbolic tangent activation function, false to
        /// use the sigmoid activation function.</param>
        /// <returns>The neural network.</returns>
        public static BasicNetwork SimpleFeedForward(int input,
                                                     int hidden1, int hidden2, int output,
                                                     bool tanh)
        {
            var pattern = new FeedForwardPattern {
                InputNeurons = input, OutputNeurons = output
            };

            if (tanh)
            {
                pattern.ActivationFunction = new ActivationTANH();
            }
            else
            {
                pattern.ActivationFunction = new ActivationSigmoid();
            }

            if (hidden1 > 0)
            {
                pattern.AddHiddenLayer(hidden1);
            }
            if (hidden2 > 0)
            {
                pattern.AddHiddenLayer(hidden2);
            }

            var network = (BasicNetwork)pattern.Generate();

            network.Reset();
            return(network);
        }
Пример #2
0
        /// <summary>
        /// Creates the feedforward network.
        /// </summary>
        /// <param name="inputsize">The inputsize.</param>
        /// <param name="outputsize">The outputsize.</param>
        /// <param name="hiddenlayers">The hiddenlayers.</param>
        /// <param name="hidden2layers">The hidden2layers.</param>
        /// <returns></returns>
        public static BasicNetwork CreateFeedforwardNetwork(int inputsize, int outputsize, int hiddenlayers, int hidden2layers)
        {
            // construct an Elman type network
            FeedForwardPattern pattern = new FeedForwardPattern();

            pattern.ActivationFunction = new ActivationTANH();
            pattern.InputNeurons       = inputsize;
            pattern.AddHiddenLayer(hiddenlayers);
            pattern.AddHiddenLayer(hidden2layers);
            pattern.OutputNeurons = outputsize;
            var network = pattern.Generate();

            return((BasicNetwork)network);
        }
Пример #3
0
        private static IMLMethod CreateFeedforwardNetwork(int input)
        {
            // construct a feedforward type network
            var pattern = new FeedForwardPattern();

            pattern.ActivationFunction = new ActivationSigmoid();
            pattern.InputNeurons       = input;
            pattern.AddHiddenLayer(5);
            pattern.OutputNeurons = 1;
            return(pattern.Generate());
        }
Пример #4
0
        public static BasicNetwork CreateNetwork()
        {
            var pattern = new FeedForwardPattern {
                InputNeurons = 3
            };

            pattern.AddHiddenLayer(50);
            pattern.OutputNeurons      = 1;
            pattern.ActivationFunction = new ActivationTANH();
            var network = (BasicNetwork)pattern.Generate();

            network.Reset();
            return(network);
        }
        private BasicNetwork CreateNetwork()
        {
            var pattern = new FeedForwardPattern {
                InputNeurons = 1
            };

            for (int i = 0; i < simSettings.HiddenLayers; i++)
            {
                pattern.AddHiddenLayer(simSettings.HiddenLayerNeurons);
            }

            pattern.OutputNeurons      = 1;
            pattern.ActivationFunction = new ActivationTANH();
            var network = (BasicNetwork)pattern.Generate();

            network.Reset();
            return(network);
        }
Пример #6
0
        public static BasicNetwork CreateNetwork(int start, int end, params int[] layers)
        {
            var pattern = new FeedForwardPattern {
                InputNeurons = start
            };

            foreach (int i in layers)
            {
                pattern.AddHiddenLayer(i);
            }

            pattern.OutputNeurons      = end;
            pattern.ActivationFunction = new ActivationTANH();
            var network = (BasicNetwork)pattern.Generate();

            network.Reset();
            return(network);
        }
        public EncogMaze(MazeInfo maze, int hiddenLayers = 1, int?hiddenLayerNeurons = null)
        {
            this.maze = maze;
            filePath  = Path.Combine(Environment.CurrentDirectory, maze.Name + "." + ENCOG_FILE_EXTENSION);

            if (!LoadNetwork())
            {
                // create new network
                var pattern = new FeedForwardPattern()
                {
                    InputNeurons = INPUT_RNEURONS, OutputNeurons = OUTPUT_RNEURONS
                };
                for (int i = 0; i < hiddenLayers; i++)
                {
                    pattern.AddHiddenLayer(hiddenLayerNeurons == null ? maze.Width * maze.Height : hiddenLayerNeurons.Value);
                }
                pattern.ActivationFunction = new ActivationTANH();
                network = (BasicNetwork)pattern.Generate();
                network.Reset();
            }
        }