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; } }
// 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); }
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; } }