-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional tests for neuron module
- Loading branch information
1 parent
bd27de6
commit adb9fa4
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
open Smolgrad.Neuron | ||
|
||
let test_neuron_initialization () = | ||
let n = Neuron.create 5 true in | ||
let n_weights = (Neuron.parameters n).weights in | ||
assert (Smolgrad.Variable.Variable.data (Neuron.parameters n).bias = 0.0); | ||
|
||
Alcotest.(check int) | ||
"Neuron: Right number of parameters are set" | ||
5 | ||
(List.length (Neuron.parameters n).weights); | ||
|
||
Alcotest.(check (float 0.0)) | ||
"Neuron: Bias is initially set to 0.0" | ||
0.0 | ||
(Smolgrad.Variable.Variable.data (Neuron.parameters n).bias); | ||
|
||
let are_weights_in_range weights = | ||
List.for_all (fun x -> (Smolgrad.Variable.Variable.data x) >= -1.0 && (Smolgrad.Variable.Variable.data x) <= 1.0) weights in | ||
|
||
Alcotest.(check bool) | ||
"Neuron: All weights are in range [-1, 1]" | ||
true | ||
(are_weights_in_range n_weights); | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters