// This method performs some animations. private void timer1_Tick(object sender, EventArgs e) { if (tabControl1.SelectedTab == tabPage2) { // Animate the points. PointDataSeries ds = chartPlotter1.DataSeries[0] as PointDataSeries; for (int i = 0; i < ds.Points.Count; i++) { PointDataSeries.ChartPoint s = ds.Points[i]; s.Coords.X += (float)((randGen.NextDouble() - 0.5) / 100.0); s.Coords.Y += (float)((randGen.NextDouble() - 0.5) / 100.0); ds.Points[i] = s; } } else if (tabControl1.SelectedTab == tabPage1) { // Animate the cosine function. if (++tickCounter == 100) { tickCounter = 0; } cosFun.Scale = Math.Sin(tickCounter / 50.0 * Math.PI) * 2.0 + 3.0; } else if (tabControl1.SelectedTab == tabPage5) { if (checkBox3.Checked) { MakeNoise(); } } }
private void ShowTeachingSet() { _teachingSetDataSeries.Points.Clear(); foreach (TeachingSet.Element elem in _teachingSet) { PointF pointLocation = new PointF((float)elem.Inputs[0], (float)elem.Inputs[1]); int output = (int)((elem.ExpectedOutputs[0] + 1.0) * 127.5); Color pointColor = Color.FromArgb(output, output, output); PointDataSeries.ChartPoint chartPoint = new PointDataSeries.ChartPoint(pointLocation, pointColor, false); _teachingSetDataSeries.Points.Add(chartPoint); } }
private void EvaluateObject() { _examinedNeuron.Weights[0] = (double)uiWeight1.Value; _examinedNeuron.Weights[1] = (double)uiWeight2.Value; double[] inputs = new double[] { (double)uiObject1.Value, (double)uiObject2.Value }; double response = _examinedNeuron.Response(inputs); double strength = _examinedNeuron.MemoryTraceStrength(StrengthNorm.Euclidean); Color signalColor; if (Math.Abs(response) < 0.2 * strength) { signalColor = Color.DarkCyan; } else if (response < 0) { signalColor = Color.Blue; } else { signalColor = Color.Red; } // 8 digits should be enough. uiResponse.Text = response.ToString("g8"); uiResponse.ForeColor = uiKeyObject.ForeColor = signalColor; PointF weightsPoint = new PointF( (float)_examinedNeuron.Weights[0], (float)_examinedNeuron.Weights[1]); PointF inputPoint = new PointF( (float)inputs[0], (float)inputs[1]); PointDataSeries.ChartPoint weightsSignal = new PointDataSeries.ChartPoint( weightsPoint, Color.Green, true); PointDataSeries.ChartPoint inputSignal = new PointDataSeries.ChartPoint( inputPoint, signalColor, true); _chartPoints.Points[0] = weightsSignal; _chartPoints.Points[1] = inputSignal; }
private void ShowOnePoint() { //{tga to eliminate DrawingLine from last point if (_lastchartPointIndexOf >= 0) { _pointDataSeries.Points.RemoveAt(_lastchartPointIndexOf); PointDataSeries.ChartPoint chartPointLast = new PointDataSeries.ChartPoint(new PointF((float)_lastchartPointX, (float)_lastchartPointY), _lastchartPointColor, false); _pointDataSeries.Points.Add(chartPointLast); } //tga} double x = _random.NextDouble() * _xScale + _xOffset; double y = _random.NextDouble() * _yScale + _yOffset; Color color = _neuronResponseFunction.Compute(x, y); PointDataSeries.ChartPoint chartPoint = new PointDataSeries.ChartPoint(new PointF((float)x, (float)y), color, true); _pointDataSeries.Points.Add(chartPoint); //{tga to eliminate DrawingLine from last point _lastchartPointIndexOf = _pointDataSeries.Points.IndexOf(chartPoint); _lastchartPointX = x; _lastchartPointY = y; _lastchartPointColor = color; //tga} uiPointCoords.Text = String.Format("Point: ({0:g6}, {1:g6})", x, y); double originalResponse = _neuronResponseFunction.Neuron.Response(new double[] { x, y }); uiResponse.Text = String.Format("Result: {0:g6}", originalResponse); uiResponse.ForeColor = color; }