public MainWindow() { InitializeComponent(); _xboxDataProvider = new XboxJoystickDataProvider(); _network = Network.Load(NeuronWeightsGenerator.Program.NetworkFile); if (!ConnectDevice()) { _timer.Elapsed += (sender, args) => ConnectDevice(); _timer.Start(); } }
public void Train() { var samples = GenerateSamples(category.Compositions); double[][] inputs = new double[samples.Length][]; double[][] outputs = new double[samples.Length][]; for (int i = 0; i < samples.Length; i++) { inputs[i] = samples[i].Inputs; outputs[i] = samples[i].Outputs; } // Create a Bernoulli activation function //var function = new BernoulliFunction(alpha: 0.5); var function = new SigmoidFunction(2); // Create a Restricted Boltzmann Machine for 6 inputs and with 1 hidden neuron //network = new RestrictedBoltzmannMachine(function, inputsCount: MAX_INPUTS, hiddenNeurons: MAX_OUTPUTS); network = new ActivationNetwork(function, MAX_INPUTS, 11, MAX_OUTPUTS); // Create the learning algorithm for RBMs /* var teacher = new ContrastiveDivergenceLearning(network) { Momentum = 0.1, LearningRate = 0.02 };*/ // create neural network /* network = new ActivationNetwork( new SigmoidFunction( 2 ), 2, // two inputs in the network 10, // two neurons in the first layer 2 ); // one neuron in the second layer*/ var teacher = new ResilientBackpropagationLearning(network as ActivationNetwork); // learn 5000 iterations for (int i = 0; i < Epochs; i++) { var e = teacher.RunEpoch(inputs,outputs); Console.WriteLine("{0} : {1}", i / (double)Epochs * 100, e); } Save(); }
public void Load() { this.network = ActivationNetwork.Load(SavePath); }
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); }
public recognizer(String n) { //Set ANN //_feature f; this.name = n; net = Network.Load(n); //recognizeFeature(); }