// Use this for initialization
 void Start()
 {
     // Setting up variables
     trainer.initalize();
     _numInputParameters = inputs.Count;
     // Initialization of network
     _network = new NeuralNetwork.NetworkModels.Network(
         _numInputParameters,
         NeuronsInHiddenLayers,
         _numOutputParameters);
     // Train the network
     if (UseEpoch)
     {
         _network.Train(trainer.getTraningData(), MaxEpoch);
     }
     else
     {
         _network.Train(trainer.getTraningData(), MinimumError);
     }
     // Shuffle initial board
     foreach (Input i in inputs)
     {
         if (Random.Range(0f, 2f) <= 1f)
         {
             i.button();
         }
     }
     output.set(0d, 1d);
 }
Пример #2
0
    void TrainNetwork()
    {
        while (true)
        {
            if (network == null)
            {
                network           = new NeuralNetwork.NetworkModels.Network(numInputs, hiddenLayer, numOutputs);
                network.LearnRate = learningRate;
                network.Momentum  = momentum;
            }

            Debug.Log("Wait, network is training, this can take a while...");

            if (trainType == TrainingType.Epoch)
            {
                network.Train(dataSets, epochs);
            }
            else
            {
                network.Train(dataSets, minimumError);
            }

            Debug.Log("Training complete!" + " Time elapsed = ");
            trained = true;
            break;
        }
    }
Пример #3
0
    public double[] Predict(double[] values)
    {
        if (trained)
        {
            double[] results = network.Compute(values);
            //Debug.Log (results [1]);
            return(new double[] { (results [0] * 60 - 30) });            //, results [1] });
        }
        else
        {
            return new double[] { 0 }
        };                                       //, 0 };
    }

    void TrainNetwork()
    {
        while (true)
        {
            if (network == null)
            {
                network           = new NeuralNetwork.NetworkModels.Network(numInputs, hiddenLayer, numOutputs);
                network.LearnRate = learningRate;
                network.Momentum  = momentum;
            }

            Debug.Log("Network is training, this can take a while...");

            if (trainType == TrainingType.Epoch)
            {
                network.Train(dataSets, epochs);
            }
            else
            {
                network.Train(dataSets, minimumError);
            }

            Debug.Log("Training complete!");
            trained = true;
            break;
        }
    }
Пример #4
0
    public void Reset()
    {
        network = null;
        trained = false;

        if (dataSets != null)
        {
            dataSets.Clear();
        }

        lineCount = 0;

        if (reader != null)
        {
            reader.Close();
        }

        if (trainingThread != null && trainingThread.IsAlive)
        {
            trainingThread.Abort();
            trainingThread = null;
        }
    }
Пример #5
0
 /// <summary>
 /// Odtwarza zserializowaną sieć neuronową z pliku
 /// </summary>
 public void Load()
 {
     NeuralNetwork = ImportHelper.ImportNetwork(LearnedNetworkFileName, new XmlSerializer());
 }