예제 #1
0
 public void SetupNetwork()
 {
     _vectors = Substitute.For<WordVectors>();
     _sentences = Substitute.For<Sentences>();
     SentenceLearner.NeuralNetworkFactory = _neuralNetworkFactory = new NeuralNetworkFactory();
     _contextMaps = new ContextMaps();
     _target = new SentenceLearner(_vectors, _sentences,_contextMaps);
 }
예제 #2
0
 public void TestNetwork()
 {
     var wordVector = new WordVector() {Name = "test"};
     var elements = new[] {0.1, 0.2, 0.3};
     elements.CopyTo(wordVector.Elements,0);
     var context = new[] {0.4, 0.5};
     var factory = new NeuralNetworkFactory();
     var network = factory.CreateNeuralNetwork(2, 2);
     var examples = new[]
     {
         new Example {Input = new [] {1.0, 0.0}, ExpectedResult = new []{1.0}},
         new Example {Input = new [] {0.0, 1.0}, ExpectedResult = new []{1.0}},
         new Example {Input = new [] {1.0, 1.0}, ExpectedResult = new []{0.0}},
         new Example {Input = new [] {0.0, 0.0}, ExpectedResult = new []{0.0}}
     };
     var error = network.Train(examples,0.1);
     var result = network.Run(new[] {0.0, 0.0});
     result[0].Should().BeLessOrEqualTo(error + 0.1);
 }
예제 #3
0
 public void TestNeuralNetworkFactory()
 {
     var target = new NeuralNetworkFactory();
     var result = target.CreateNeuralNetwork(3, 2);
     result.Should().BeAssignableTo<AForgeNeuralNetwork>();
 }
예제 #4
0
 static SentenceLearner()
 {
     NeuralNetworkFactory = new NeuralNetworkFactory();
 }