test/neural_network/backpropagation_test.rb in ai4r-1.9 vs test/neural_network/backpropagation_test.rb in ai4r-1.11
- old
+ new
@@ -13,11 +13,11 @@
# the Mozilla Public License version 1.1 as published by the
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
#
-require File.dirname(__FILE__) + '/../../lib/ai4r/neural_network/backpropagation'
+require 'ai4r/neural_network/backpropagation'
require 'test/unit'
Ai4r::NeuralNetwork::Backpropagation.send(:public, *Ai4r::NeuralNetwork::Backpropagation.protected_instance_methods)
Ai4r::NeuralNetwork::Backpropagation.send(:public, *Ai4r::NeuralNetwork::Backpropagation.private_instance_methods)
@@ -60,10 +60,23 @@
net = Backpropagation.new([2, 4, 8, 10, 7])
y = net.eval([2, 3])
assert y.length == 7
end
+ def test_dump
+ net = Backpropagation.new([3, 2]).init_network
+ s = Marshal.dump(net)
+ x = Marshal.load(s)
+ assert_equal net.structure, x.structure
+ assert_equal net.disable_bias, x.disable_bias
+ assert_equal net.learning_rate, x.learning_rate
+ assert_equal net.momentum, x.momentum
+ assert_equal net.weights, x.weights
+ assert_equal net.last_changes, x.last_changes
+ assert_equal net.activation_nodes, x.activation_nodes
+ end
+
end
end
-end
\ No newline at end of file
+end