lib/brainz/backpropagation.rb in brainz-0.1.1 vs lib/brainz/backpropagation.rb in brainz-0.1.2
- old
+ new
@@ -1,17 +1,21 @@
module Brainz
module Algorithms
module Backpropagation
def update(input)
- @network ||= ::Brainz::Network.new(
- @num_input, [num_hidden, @num_output * 2], @num_output, momentum: momentum, learning_rate: learning_rate
- )
+ initialize_network unless @network
@network.update(input)
self
end
def fix_weights(targets)
@network.fix_weights(targets)
+ end
+
+ def initialize_network
+ @network ||= ::Brainz::Network.new(
+ num_input, num_hidden, num_output, momentum: momentum, learning_rate: learning_rate
+ )
end
end
end
end
\ No newline at end of file