Compute() public method

Compute output vector of the network.

The actual network's output vecor is determined by layers, which comprise the layer - represents an output vector of the last layer of the network. The output vector is also stored in Output property.

The method may be called safely from multiple threads to compute network's output value for the specified input values. However, the value of Output property in multi-threaded environment is not predictable, since it may hold network's output computed from any of the caller threads. Multi-threaded access to the method is useful in those cases when it is required to improve performance by utilizing several threads and the computation is based on the immediate return value of the method, but not on network's output property.

public Compute ( double input ) : double[]
input double Input vector.
return double[]
Example #1
0
        private static void getStatistics(Network network, FsdParser parser, double threshold,
            out int numTradesWon, out int numTradesLost, out double tradeWinRate)
        {
            numTradesWon = 0;
            numTradesLost = 0;

            int numSamples = parser.InputVectors.Length;

            for (int sampleIdx = 0; sampleIdx < numSamples; sampleIdx++)
            {
                double[] computed = network.Compute(parser.InputVectors[sampleIdx]);

                if (computed[0] > threshold && computed[1] < threshold)
                {
                    // Netzwerk hat "Rise" errechnet
                    if (parser.OutputVectors[sampleIdx][0] == 1)
                    {
                        numTradesWon++;
                    }
                    else
                    {
                        numTradesLost++;
                    }
                }
                else if (computed[1] > threshold && computed[0] < threshold)
                {
                    // Netzwerk hat "Fall" errechnet
                    if (parser.OutputVectors[sampleIdx][1] == 1)
                    {
                        numTradesWon++;
                    }
                    else
                    {
                        numTradesLost++;
                    }
                }
            }

            tradeWinRate = (double)numTradesWon / (numTradesWon + numTradesLost);
        }