List <double> Train(double x, double y, double r) { return(ann.Go(new List <double> { x, y }, new List <double> { r })); }
List <double> Train(double i1, double i2, double o) { List <double> inputs = new List <double>(); List <double> outputs = new List <double>(); inputs.Add(i1); inputs.Add(i2); outputs.Add(o); return(ann.Go(inputs, outputs)); }
private List <double> Train(int i1, int i2, int o) { List <double> inputs = new List <double>(); List <double> outputs = new List <double>(); inputs.Add(i1); inputs.Add(i2); outputs.Add(o); return(model.Go(inputs, outputs)); }
/// <summary> /// Set parameters for training /// </summary> /// <param name="input1"></param> /// <param name="input2"></param> /// <param name="output"></param> /// <returns></returns> List <double> Train(double input1, double input2, double output) //can change it for more inputs and outputs. //for example how to onload data from DB here and work with it and after that save it { List <double> inputs = new List <double>(); List <double> outputs = new List <double>(); inputs.Add(input1); inputs.Add(input2); outputs.Add(output); return(ann.Go(inputs, outputs)); }
// Use this for initialization void Start() { List <double> result = new List <double>(); ann = new ANN(2, 1, 1, 2, 0.8f); for (int i = 0; i < 10000; i++) { sumSquareError = 0; result = ann.Go(new List <double> { 0, 0 }, new List <double> { 0 }); sumSquareError += Mathf.Pow((float)result[0] - 0, 2); result = ann.Go(new List <double> { 0, 1 }, new List <double> { 1 }); sumSquareError += Mathf.Pow((float)result[0] - 1, 2); result = ann.Go(new List <double> { 1, 0 }, new List <double> { 1 }); sumSquareError += Mathf.Pow((float)result[0] - 1, 2); result = ann.Go(new List <double> { 1, 1 }, new List <double> { 0 }); sumSquareError += Mathf.Pow((float)result[0] - 0, 2); } Debug.Log("SSE: " + sumSquareError); }
private List <double> Run(double bx, double by, double bvx, double bvy, double px, double py, double pv, bool train) { List <double> inputs = new List <double>(); List <double> outputs = new List <double>(); inputs.Add(bx); inputs.Add(by); inputs.Add(bvx); inputs.Add(bvy); inputs.Add(px); inputs.Add(py); outputs.Add(pv); if (train) { return(ann.Train(inputs, outputs)); } else { return(ann.Go(inputs, outputs)); } }