示例#1
0
    void CreateNewNetwork()
    {
        LinearLayer  inputLayer   = new LinearLayer(neurons);
        SigmoidLayer hiddenLayer  = new SigmoidLayer(hidden1Neurons);
        SigmoidLayer hiddenLayer2 = new SigmoidLayer(hidden2Neurons);


        LinearLayer outputLayer = new LinearLayer(outputNum);


        BackpropagationConnector conn1 = new BackpropagationConnector(inputLayer, hiddenLayer);

        conn1.Initializer = new RandomFunction(0d, 0.001d);
        BackpropagationConnector conn3 = new BackpropagationConnector(hiddenLayer, hiddenLayer2);

        conn3.Initializer = new RandomFunction(0d, 0.001d);
        BackpropagationConnector conn2 = new BackpropagationConnector(hiddenLayer2, outputLayer);

        conn2.Initializer = new RandomFunction(0d, 0.001d);

        conn1.Initialize();
        conn2.Initialize();
        conn3.Initialize();


        neuralNetwork = new BackpropagationNetwork(inputLayer, outputLayer);
        neuralNetwork.SetLearningRate(learningRate);

        neuralNetwork.Initialize();
    }
示例#2
0
    void CreateNewNetwork()
    {
        Debug.Log("Creating new network...");

        LinearLayer  inputLayer   = new LinearLayer(neurons);
        SigmoidLayer hiddenLayer  = new SigmoidLayer(hidden1Neurons);
        SigmoidLayer hiddenLayer2 = new SigmoidLayer(hidden2Neurons);

        LinearLayer outputLayer = new LinearLayer(outputNum);


        BackpropagationConnector conn1 = new BackpropagationConnector(inputLayer, hiddenLayer);

        conn1.Initializer = new RandomFunction(0d, 0.00001d);
        BackpropagationConnector conn3 = new BackpropagationConnector(hiddenLayer, hiddenLayer2);

        conn3.Initializer = new RandomFunction(0d, 0.00001d);
        BackpropagationConnector conn2 = new BackpropagationConnector(hiddenLayer2, outputLayer);

        conn2.Initializer = new RandomFunction(0d, 0.00001d);

        conn1.Initialize();
        conn2.Initialize();
        conn3.Initialize();


        if (NetworkManager.Instance._neuralNetwork != null)
        {
            Debug.Log("A network already exists... new network will overwrite it");
        }
        Debug.Log("Created.");

        NetworkManager.Instance._neuralNetwork = new BackpropagationNetwork(inputLayer, outputLayer);
        NetworkManager.Instance._neuralNetwork.SetLearningRate(learningRate);
        NetworkManager.Instance.setNeuralNetwork(NetworkManager.Instance._neuralNetwork);

        NetworkManager.Instance.InitializeNetwork(neurons);
    }