void FixedUpdate() { //set training lap count and get inputs from sensors lapCount = Lap.lapCount; Inputs = GetComponent <Sensor>().sensors; //get steering and torque during training double steer = Input.GetAxis("Horizontal"); double torque = Input.GetAxis("Vertical"); //change steering values to be between -1 and 1 if (steer < 0) { steer = (steer * 0.5) + 0.5; } else if (steer > 0) { steer = (steer + 1) / 2; } else { steer = 0.5; } //if still training if (lapCount <= NoLaps) { //feed inputs, backpropogate expected values and hide training panel backProp.FeedForward(Inputs); backProp.Propogate(new double[] { steer, torque }, LearningRate); AutoPanel.SetActive(false); //when finished training } else { //set the backprop alg as driver, feed inputs to create outputs Rigidbody.GetComponent <CarPhysics>().driver = Driver.BackProp; Outputs = backProp.FeedForward(Inputs); //set outputs to CarController class controller.BackPropSteering = Outputs[0]; controller.BackPropEngine = Outputs[1]; //show training panel and tell user to release all controls AutoPanel.SetActive(true); if (runOnce) { StartCoroutine(CountStart()); runOnce = false; } } }
void FixedUpdate() { //Load trained car, get inputs from sensors LoadChild(); Inputs = GetComponent <Sensor>().sensors; //feed inputs of sensors, get outputs, and set outputs to CarController class Outputs = backProp.FeedForward(Inputs); controller.BackPropSteering = Outputs[0]; controller.BackPropEngine = Outputs[1]; }
public void FeedForward2() { // ARRANGE BackPropNetwork backprop = new BackPropNetwork(); double[] inputs = { 0.6, 0.4, 0.2, 0, 0 }; int expectedlength = 2; // ACT double[] outputs = backprop.FeedForward(inputs); // ASSERT Assert.That(outputs.Length, Is.EqualTo(expectedlength)); foreach (var output in outputs) { Assert.That(output, Is.InRange(-1f, 1f)); } }