Guest User

Untitled

a guest
Oct 11th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. # little specs
  2. require_relative '../backpropogation.rb'
  3.  
  4. describe 'Function testing' do
  5. it "should return correct weights" do
  6. structure = [2,3,1]
  7. nn = NeuralNetwork.new structure
  8.  
  9. # should print [ [ [1, 2, 3], [1, 2, 3] ], [ [1], [2], [3] ] ]
  10. nn.weights[0].count.should == 2
  11. nn.weights[1].count.should == 3
  12. nn.weights[0][0].count.should == 3
  13. nn.weights[0][1].count.should == 3
  14. nn.weights[1][0].count.should == 1
  15. nn.weights[1][1].count.should == 1
  16. nn.weights[1][2].count.should == 1
  17.  
  18. structure = [3, 5, 2, 3]
  19. #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] ] ]
  20. nn = NeuralNetwork.new structure
  21. nn.weights[0].count.should == 3
  22. nn.weights[1].count.should == 5
  23. nn.weights[2].count.should == 2
  24. nn.weights[0][0].count.should == 5
  25. nn.weights[0][1].count.should == 5
  26. nn.weights[0][2].count.should == 5
  27. nn.weights[1][0].count.should == 2
  28. nn.weights[1][1].count.should == 2
  29. nn.weights[2][1].count.should == 3
  30.  
  31. end
  32.  
  33. it "should correct calculate outputs" do
  34. structure = [2, 3, 2, 1]
  35. nn = NeuralNetwork.new structure
  36.  
  37. input = [1,2]
  38. nn.evaluate( input )
  39. nn.outputs[0].count.should == 3
  40. nn.outputs[1].count.should == 2
  41. nn.outputs[2].count.should == 1
  42. end
  43.  
  44. it "should correct calculate deltas" do
  45. structure = [2, 3, 2, 1]
  46. nn = NeuralNetwork.new structure
  47.  
  48. input = [1,2]
  49. right = [0.5]
  50. nn.train( input, right )
  51. end
  52.  
  53. it "should correct update weights" do
  54. end
  55. end
Add Comment
Please, Sign In to add comment