public void TanH2() { // ARRANGE BackPropNetwork backprop = new BackPropNetwork(); List <double> inputs = new List <double> { 0.0, 0.7, 0.4, 0.1, 0.2222 }; // ACT List <double> outputs = new List <double>(); foreach (var input in inputs) { outputs.Add(backprop.TanH(input)); } // ASSERT foreach (var output in outputs) { Assert.That(output, Is.InRange(0f, 1f)); } }
public ImageCompress() { int[] layersizes = new int[3] { 8, 18, 8 }; ActivationFunction[] activFunctions = new ActivationFunction[3] { ActivationFunction.None, ActivationFunction.Sigmoid, ActivationFunction.Linear }; XmlDocument xdoc = new XmlDocument(); xdoc.Load(Server.MapPath("resources/ann.xml")); ds = new DataSet(); ds.Load((XmlElement)xdoc.DocumentElement.ChildNodes[0]); bpnetwork = new BackPropNetwork(layersizes, activFunctions); nt = new NetworkTrainer(bpnetwork, ds); nt.maxError = 0.00001; nt.maxiterations = 10000; nt.nudgewindow = 500; nt.traininrate = 0.1; nt.TrainDataset(); // save error double[] err = nt.geteHistory(); string[] filedata = new string[err.Length]; for (int i = 0; i < err.Length; i++) { filedata[i] = i.ToString() + " " + err[i].ToString(); } }
public void TanH1() { // ARRANGE BackPropNetwork backprop = new BackPropNetwork(); List <double> inputs = new List <double> { 0.056566161, 0.3651, 0.268461, 0.00005, 0.00123005, 0.0, 0.0000125, 0.0440005, 1 }; // ACT List <double> outputs = new List <double>(); foreach (var input in inputs) { outputs.Add(backprop.TanH(input)); } // ASSERT foreach (var output in outputs) { Assert.That(output, Is.InRange(0f, 1f)); } }
//Restarts training process public void RestartCurrent() { ResetCarPosition(); backProp = new BackPropNetwork(); Lap.lapCount = 0; Rigidbody.GetComponent <CarPhysics>().driver = Driver.USER; runOnce = true; }
//Initialise objects void Start() { Rigidbody = GetComponent <Rigidbody>(); backProp = new BackPropNetwork(); Rigidbody.GetComponent <CarPhysics>().driver = Driver.BackProp; controller = new CarController(); saveLoad = new BackPropWeights(); Rigidbody.GetComponent <Sensor>().sensorLenght += 5; position = new ResetPosition(); }
public void Random2() { // ARRANGE BackPropNetwork backprop = new BackPropNetwork(); // ACT double random = backprop.GetRandomWeight(); // ASSERT Assert.That(random, Is.InRange(-1f, 1f)); }
//Initialise objects void Start() { Rigidbody = GetComponent <Rigidbody>(); Reset.onClick.AddListener(ResetCurrent); Restart.onClick.AddListener(RestartCurrent); LearningRate = LearningModeScript.LearningRate; NoLaps = LearningModeScript.NoLaps; backProp = new BackPropNetwork(); Rigidbody.GetComponent <CarPhysics>().driver = Driver.USER; controller = new CarController(); saveLoad = new BackPropWeights(); Rigidbody.GetComponent <Sensor>().sensorLenght += 5; position = new ResetPosition(); }
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)); } }
public void Init1() { // ARRANGE BackPropNetwork backprop = new BackPropNetwork(); int expectedlength = 3; // ACT // ASSERT Assert.That(backprop.GetWeights().Count, Is.EqualTo(expectedlength)); Assert.That(backprop.weightsDer.Count, Is.EqualTo(expectedlength)); Assert.That(backprop.layerInputs.Count, Is.EqualTo(expectedlength)); Assert.That(backprop.layerOutputs.Count, Is.EqualTo(expectedlength)); Assert.That(backprop.layerLoss.Count, Is.EqualTo(expectedlength)); Assert.That(backprop.GetWeights().GetType() == typeof(List <double[][]>)); Assert.That(backprop.weightsDer.GetType() == typeof(List <double[][]>)); Assert.That(backprop.layerInputs.GetType() == typeof(List <double[]>)); Assert.That(backprop.layerOutputs.GetType() == typeof(List <double[]>)); Assert.That(backprop.layerLoss.GetType() == typeof(List <double[]>)); }
public CompressText() { int[] layersizes = new int[10] { 1, 10, 9, 8, 7, 5, 4, 3, 2, 1 }; ActivationFunction[] activFunctions = new ActivationFunction[10] { ActivationFunction.None, ActivationFunction.Gaussian, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Sigmoid, ActivationFunction.Linear }; XmlDocument xdoc = new XmlDocument(); xdoc.Load(Path.Combine(HttpRuntime.AppDomainAppPath, "resources/ann.xml")); ds = new DataSet(); ds.Load((XmlElement)xdoc.DocumentElement.ChildNodes[0]); bpnetwork = new BackPropNetwork(layersizes, activFunctions); nt = new NetworkTrainer(bpnetwork, ds); nt.maxError = 0.1; nt.maxiterations = 10000; nt.traininrate = 0.1; nt.TrainDataset(); // save error double[] err = nt.geteHistory(); string[] filedata = new string[err.Length]; for (int i = 0; i < err.Length; i++) { filedata[i] = i.ToString() + " " + err[i].ToString(); } }