Exemplo n.º 1
0
    public void LoadNNDatasource(string fileName, int expectedNumInputs, int expectedOutputs)
    {
      string[] allLines = File.ReadAllLines(fileName);

      for (int i = 0; i < allLines.Length; i++)
      {
        NNDataSource item = new NNDataSource(allLines[i], expectedNumInputs, expectedOutputs);
        neuralNetDataSource.Add((T)item);
      }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Returns the prediction of the network for a given input.
    /// </summary>
    /// <param name="dataSource"></param>
    /// <returns></returns>
    public double[] getNetworkPrediction(NNDataSource dataSource)
    {
      double[] networkOutputs = new double[OUTPUT_NEURONS];
      double[] networkInputs = new double[INPUT_NEURONS];
      dataSource.returnInput(ref networkInputs);

      network.Compute(networkInputs, networkOutputs);

      if (networkOutputs.Length != OUTPUT_NEURONS)
        throw new Exception("Unexpected number of network ouputs.");

      return networkOutputs;
    }