private static BlackBoxProbe CreateBlackBoxProbe(IFunction fn, ParamSamplingInfo paramSamplingInfo) { // Determine the mid output value of the function (over the specified sample points) and a scaling factor // to apply the to neural network response for it to be able to recreate the function (because the neural net // output range is [0,1] when using the logistic function as the neuron activation function). FnRegressionUtils.CalcFunctionMidAndScale(fn, paramSamplingInfo, out double mid, out double scale); var blackBoxProbe = new BlackBoxProbe(paramSamplingInfo, mid, scale); return(blackBoxProbe); }
/// <summary> /// Constructs with the details of the function regression problem to be visualized. /// </summary> /// <param name="fn">The function being regressed.</param> /// <param name="generativeMode">Indicates that blackbox has no inputs; it will generate a waveform as a function of time.</param> /// <param name="paramSamplingInfo">Parameter sampling info.</param> /// <param name="genomeDecoder">Genome decoder.</param> public FnRegressionView2D(IFunction fn, ParamSamplingInfo paramSamplingInfo, bool generativeMode, IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder) { InitializeComponent(); InitGraph(string.Empty, string.Empty, string.Empty); _fn = fn; _paramSamplingInfo = paramSamplingInfo; _generativeMode = generativeMode; _genomeDecoder = genomeDecoder; // Determine the mid output value of the function (over the specified sample points) and a scaling factor // to apply the to neural network response for it to be able to recreate the function (because the neural net // output range is [0,1] when using the logistic function as the neuron activation function). double mid, scale; FnRegressionUtils.CalcFunctionMidAndScale(fn, paramSamplingInfo, out mid, out scale); if (generativeMode) { _blackBoxProbe = new GenerativeBlackBoxProbe(paramSamplingInfo, mid, scale); } else { _blackBoxProbe = new BlackBoxProbe(paramSamplingInfo, mid, scale); } _yArrTarget = new double[paramSamplingInfo._sampleCount]; // Pre-build plot point objects. _plotPointListTarget = new PointPairList(); _plotPointListResponse = new PointPairList(); double[] xArr = paramSamplingInfo._xArr; for (int i = 0; i < xArr.Length; i++) { double x = xArr[i]; _plotPointListTarget.Add(x, _fn.GetValue(x)); _plotPointListResponse.Add(x, 0.0); } // Bind plot points to graph. zed.GraphPane.AddCurve("Target", _plotPointListTarget, Color.Black, SymbolType.None); zed.GraphPane.AddCurve("Network Response", _plotPointListResponse, Color.Red, SymbolType.None); }