public PasswordChecker(string datasetFile) { _nn = new NeuronNetwork(COUNT_IPNUT_NEURONS, LEARNING_RATE); foreach (var line in File.ReadLines(datasetFile)) { var data = line.Split(" "); try { var result = int.Parse(data[1]); switch (result) { case 0: result = -1; break; case 1: result = 0; break; case 2: result = 1; break; default: continue; } _nn.Train(result, ParsePassword(data[0])); } catch { } } }
public void TestMethod1() { var neuronNetwork = new NeuronNetwork(2, 6, new NeuronNetworkContext { Derivative = x => x * (1 - x), Function = x => 1.0 / (1.0 + Math.Exp(-x)), LearnEpoch = 10000, LearnStep = 0.5, ErrorTolerance = 0.001 }); neuronNetwork.Train(new[] { new[] { 1d, 0d }, new[] { 0d, 1d }, new[] { 1d, 1d }, new[] { 0d, 0d } }, new[] { 1d, 1d, 0d, 0d }, (i, i1) => { }); var result = neuronNetwork.Process(new[] { 1d, 1d }); Assert.IsTrue(result < 0.5); result = neuronNetwork.Process(new[] { 1d, 0d }); Assert.IsTrue(result > 0.5); }