-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from opennars/pr_codegen08042018
Auto ML codegen: records a useful macro for a FF NN
- Loading branch information
Showing
1 changed file
with
9 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
' weighted sum of all elements - used all over the place for NN's | ||
' with a compact vector representation because the (NARS-term)complexity is a issue here | ||
<<(*,$1,$2,$3) --> [maddv]> =|> <(*,$1,$2,$3) --> [weighted]>>. | ||
' we need to add a bias | ||
<(&/, <(*,$1,$2,$3) --> [maddv]>, +1, <(*,$1,bias,$1) --> [add]>, +1) =/> <(*,$1,$2,$3) --> [weighted]>>. | ||
|
||
|
||
' multiply add $1 = $1 + $2 * $3 | ||
< (^pick, {SELF}, madd, $1, $2, $3) =/> <(*, $1, $2, $3) --> [madd]> >. | ||
|
||
' multiply add vector, result is $1, vectors are $2 and $3 | ||
< (^pick, {SELF}, maddv, $1, $2, $3) =/> <(*, $1, $2, $3) --> [maddv]> >. | ||
|
||
' add | ||
< (^pick, {SELF}, add, $1, $2, $3) =/> <(*, $1, $2, $3) --> [add]> >. | ||
|
||
|
||
' old more simpler example | ||
'<(*, v0, v1, v1) --> [madd]>! | ||
'<(*, v2, v1, v1) --> [madd]>! | ||
' indirection to call an action which finishes the recording of the macro | ||
<(&/, <(*, res0, a0, b0) --> [weighted]>, +10, (^pick, {SELF}, fin), +10) =/> <(*, res0, a0, b0) --> [weighted2]> >. | ||
|
||
' request to generate the code for a weighted sum | ||
<(*, res0, a0, b0) --> [weighted]>! | ||
<(*, res0, a0, b0) --> [weighted2]>! |