public void return_0_point_26894142_when_it_has_no_hidden_layers_entry_values_are_2_and_4_threshold_is_minus7_and_weights_are_1() { _thresholdGenerator.Generate().Returns(-7.0); _weightGenerator.Generate().Returns(1.0); var neuralNetwork = new NeuralNetworkBuilder(new ConnectionProperties(_weightGenerator), new PerceptronProperties(_thresholdGenerator), new AcceptanceMatcher(0.0, 0.0)) .WithLayer(1).From(2).To(1) .Build(); neuralNetwork.EntryValues = new ValueList<double> { 2.0, 4.0 }; neuralNetwork.Execute(); neuralNetwork.ExitValues[1].Should().BeApproximately(0.26894142, 0.00000001); }
public void return_0_point_5_when_it_has_no_hidden_layers_entry_value_is_0_threshold_is_0_and_weight_is_1() { _thresholdGenerator.Generate().Returns(0.0); _weightGenerator.Generate().Returns(1.0); var neuralNetwork = new NeuralNetworkBuilder(new ConnectionProperties(_weightGenerator), new PerceptronProperties(_thresholdGenerator), new AcceptanceMatcher(0.0, 0.0)) .WithLayer(1).From(1).To(1) .Build(); neuralNetwork.EntryValues = new ValueList<double> { 0.0 }; neuralNetwork.Execute(); neuralNetwork.ExitValues[1].Should().Be(0.5); }
public void return_an_exit_value_of_0_when_perceptrons_have_a_very_low_threshold() { _thresholdGenerator.Generate().Returns(-9999.0); _weightGenerator.Generate().Returns(1.0); var neuralNetwork = new NeuralNetworkBuilder(new ConnectionProperties(_weightGenerator), new PerceptronProperties(_thresholdGenerator), new AcceptanceMatcher(0.0, 0.0)) .WithLayer(1).From(1).To(1) .WithLayer(2).From(1).To(1) .Build(); neuralNetwork.Execute(); neuralNetwork.ExitValues[1].Should().Be(0.0); }
public void return_correct_modified_weight_for_a_single_layer() { _thresholdGenerator.Generate().Returns(0.0); _weightGenerator.Generate().Returns(1.0); var neuralNetwork = new NeuralNetworkBuilder(new ConnectionProperties(_weightGenerator), new PerceptronProperties(_thresholdGenerator), new AcceptanceMatcher(0.0, 0.0)) .WithLayer(1).From(2).To(2) .WithLayer(2).From(2).To(2) .WithLayer(3).From(2).To(2) .WithLayer(4).From(2).To(2) .Build(); neuralNetwork.EntryValues = new ValueList<double> { 0.2, 0.4, 0.6, 0.8 }; neuralNetwork.ExpectedExitValues = new ValueList<double> { 0.9, 0.6, 0.3, 0.0 }; neuralNetwork.Execute(); neuralNetwork.ExecuteBackPropagation(); }