spec/convolver_spec.rb in convolver-0.0.1 vs spec/convolver_spec.rb in convolver-0.0.2
- old
+ new
@@ -79,6 +79,28 @@
[ [ [ 8.5, 8.2 ], [ 11.34, 9.68 ] ], [ [ 7.68, 6.56 ], [ 11.24, 7.16 ] ], [ [ 9.14, 6.54 ], [ 12.44, 9.2 ] ] ],
[ [ [ 8.5, 8.2 ], [ 11.34, 9.68 ] ], [ [ 7.68, 6.56 ], [ 11.24, 7.16 ] ], [ [ 9.14, 6.54 ], [ 12.44, 9.2 ] ] ]
]
end
end
+
+ describe "#nn_run_layer" do
+ it "should calculate basic layer rules" do
+ inputs = NArray[ 1.0 ]
+ weights = NArray[ [ 1.0 ] ]
+ thresholds = NArray[ 0.0 ]
+ outputs = Convolver.nn_run_layer( inputs, weights, thresholds );
+ outputs.should be_narray_like NArray[ 1.0 ]
+
+ inputs = NArray[ 0.5, -0.5 ]
+ weights = NArray[ [ 1.0, 2.0 ], [ 2.0, 1.0 ] ]
+ thresholds = NArray[ 0.0, 0.0 ]
+ outputs = Convolver.nn_run_layer( inputs, weights, thresholds );
+ outputs.should be_narray_like NArray[ 0.0, 0.5 ]
+
+ inputs = NArray[ 0.3, -0.4, 0.8, -0.7 ]
+ weights = NArray[ [ 1.0, 0.25, 0.5, -0.5 ], [ -1.0, -0.25, -0.5, 0.5 ] ]
+ thresholds = NArray[ 0.0, 0.0 ]
+ outputs = Convolver.nn_run_layer( inputs, weights, thresholds );
+ outputs.should be_narray_like NArray[ 0.95, 0.0 ]
+ end
+ end
end