private void _ThrowingManagment() { if (_thrower.IsReady()) { List <TrajectoryData> collectedData = _thrower.CollectTrajecoryData(); if (collectedData.Count > 0) { float throwDistance; var directionToLern = dataProcessor.findOptimalThrowDirection(collectedData, target, LastThrowDirection, out throwDistance); _deviationFactor = (float)Sigmoid.Output((double)throwDistance * 0.5 - 2) * 0.4f; var ppDirToLern = (directionToLern + Vector3.one) * 0.5f; if (!_first) { neuralService.NetAdaptation(_lastThrowPosition, target.GetTargetCords(), ppDirToLern); } } var throwPosition = _thrower.GetThrowPosition(); var calcualtedDirection = neuralService.CalculateThrowDirection(throwPosition, target.GetTargetCords()); var ppDir = calcualtedDirection * 2 - Vector3.one; _thrower.DataGatteringThrow(ppDir, _deviationFactor); LastThrowDirection = ppDir; _lastThrowPosition = throwPosition; _first = false; } }
private void collectLearningdata() { using (var writer = File.AppendText(LearnignDataFileName)) { var expectedOutput = Sigmoid.Output(DistanceToRightWall - DistanceToLeftWall); Debug.Log(expectedOutput); writer.WriteLine(string.Format("{0}{3}{1}{3}{2}", DistanceToLeftWall, DistanceToRightWall, expectedOutput, learningFileDelimiter)); Debug.Log(DistanceToLeftWall + " " + DistanceToRightWall + " " + expectedOutput); } }
public void Compute() { float sum = 0; for (int i = 0; i < InputNeurons.Count; i++) { sum += InputNeurons[i].OutputValue * Weights[i]; } OutputValue = Sigmoid.Output(sum + Weights[Weights.Count - 1]); }
public float CalculateValue() { /*for (int i = 0; i < InputSynapses.Count; i++) * { * xSum += InputSynapses[i].Weight * InputSynapses[i].InputNeuron.Value; * } ****** é o mesmo que fazer o Sum do LINQ */ float xSum = InputSynapses.Sum(x => x.Weight * x.InputNeuron.Value); float u = xSum + Bias; Value = Sigmoid.Output(u); return(Value); }
public List <float> GetInputs() { List <float> inputs = new List <float>(); float angle = GameObject.transform.rotation.eulerAngles.magnitude * Mathf.Deg2Rad; for (int i = 0; i < ConfigManager.config.neuralNet.nInputNeurons; i++) { float startingRot = ConfigManager.config.simulation.individualRaycastStartingRotation; float rotationStep = ConfigManager.config.simulation.individualRaycastRotationStep; float realAngle = angle + startingRot + rotationStep * i; RaycastHit2D hit = Physics2D.Raycast(GameObject.transform.position, new Vector2(Mathf.Cos(realAngle), Mathf.Sin(realAngle)), 2); //Debug.DrawRay(GameObject.transform.position, new Vector3(Mathf.Cos(realAngle), Mathf.Sin(realAngle), 0), Color.red, 8); inputs.Add(hit.collider ? Sigmoid.Output(hit.distance / ConfigManager.config.neuralNet.inputEase) : 0); } return(inputs); }
public virtual double CalculateValue() { return(Value = Sigmoid.Output(InputSynapses.Sum(a => a.Weight * a.InputNeuron.Value) + Bias)); }
public float CalculateValue() { return(Value = Sigmoid.Output(InputSynapses.Sum(x => x.Weight * x.InputNeuron.Value) + Bias)); }