public void TestStaticWeightsPreserved() { double[] weights = null; _target.SaveTo(ref weights); var net2 = new AForgeNeuralNetwork(4, 5, 2); net2.Theta.LoadFrom(weights); var result1 = _net1.Run(new[] { 0.3, 0.4, 0.0, 0.0}); var result2 = net2.Run(new[] { 0.3, 0.4, 0.0, 0.0 }); _net1.HiddenLayer[0].Should().NotBe(net2.HiddenLayer[0],"Static weights from neurons were not preserved after LoadFrom"); }
public void TestNonStaticWeightsRestored() { double[] weights = null; _target.SaveTo(ref weights); var net2 = new AForgeNeuralNetwork(4, 5, 2); net2.Theta.LoadFrom(weights); _net1.UnderlyingNetwork.Layers[0].Neurons[0].Weights[3].Should().Be(net2.UnderlyingNetwork.Layers[0].Neurons[0].Weights[3]); var result1 = _net1.Run(new[] { 0.0, 0.0, 0.4, 0.5}); var result2 = net2.Run(new[] { 0.0, 0.0, 0.4, 0.5}); _net1.HiddenLayer[0].Should().Be(net2.HiddenLayer[0], "same inputs with restored weights"); }