Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # little specs
- require_relative '../backpropogation.rb'
- describe 'Function testing' do
- it "should return correct weights" do
- structure = [2,3,1]
- nn = NeuralNetwork.new structure
- # should print [ [ [1, 2, 3], [1, 2, 3] ], [ [1], [2], [3] ] ]
- nn.weights[0].count.should == 2
- nn.weights[1].count.should == 3
- nn.weights[0][0].count.should == 3
- nn.weights[0][1].count.should == 3
- nn.weights[1][0].count.should == 1
- nn.weights[1][1].count.should == 1
- nn.weights[1][2].count.should == 1
- structure = [3, 5, 2, 3]
- #should print [ [ [1, 2, 3, 4, 5], [1,2,3,4,5], [1,2,3,4,5] ], [ [1,2], [1,2], [1,2], [1,2], [1,2] ], [ [1,2,3], [1,2,3] ] ]
- nn = NeuralNetwork.new structure
- nn.weights[0].count.should == 3
- nn.weights[1].count.should == 5
- nn.weights[2].count.should == 2
- nn.weights[0][0].count.should == 5
- nn.weights[0][1].count.should == 5
- nn.weights[0][2].count.should == 5
- nn.weights[1][0].count.should == 2
- nn.weights[1][1].count.should == 2
- nn.weights[2][1].count.should == 3
- end
- it "should correct calculate outputs" do
- structure = [2, 3, 2, 1]
- nn = NeuralNetwork.new structure
- input = [1,2]
- nn.evaluate( input )
- nn.outputs[0].count.should == 3
- nn.outputs[1].count.should == 2
- nn.outputs[2].count.should == 1
- end
- it "should correct calculate deltas" do
- structure = [2, 3, 2, 1]
- nn = NeuralNetwork.new structure
- input = [1,2]
- right = [0.5]
- nn.train( input, right )
- end
- it "should correct update weights" do
- end
- end
Add Comment
Please, Sign In to add comment