Skip to content

Commit

Permalink
doc: readme, syntax highlighting for scheme sample
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianlm committed Jun 11, 2012
1 parent 511a83a commit 5a36fdd
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions README.md
Expand Up @@ -14,30 +14,32 @@ need to be freed with their associated destroyers.
## Example
Here's the [original example](http://leenissen.dk/fann/html/files2/gettingstarted-txt.html) convered to scheme:

(use fann)
(define xor-train (fann:read-train-from-list '(((-1 -1) (-1))
((-1 1) (1))
((1 -1) (1))
((1 1) (-1)))))
```scheme
(use fann)
(define xor-train (fann:read-train-from-list '(((-1 -1) (-1))
((-1 1) (1))
((1 -1) (1))
((1 1) (-1)))))
(define ann (fann:create-standard 2 3 1))
(define ann (fann:create-standard 2 3 1))
(let* ([max-epochs 500000]
[epochs-between-reports 1000]
[desired-error 0.001]
[num-inputs 2]
[num-outputs 1])
(let* ([max-epochs 500000]
[epochs-between-reports 1000]
[desired-error 0.001]
[num-inputs 2]
[num-outputs 1])
(fann:set-activation-function-hidden ann fann:sigmoid-symmetric)
(fann:set-activation-function-output ann fann:sigmoid-symmetric)
(fann:train-on-data ann xor-train max-epochs epochs-between-reports desired-error))
(fann:set-activation-function-hidden ann fann:sigmoid-symmetric)
(fann:set-activation-function-output ann fann:sigmoid-symmetric)
(fann:train-on-data ann xor-train max-epochs epochs-between-reports desired-error))
(define input '(-1 1))
(print input " -> " (fann:run ann input))
(define input '(-1 1))
(print input " -> " (fann:run ann input))
(fann:save ann "/tmp/xor-test.net")
(fann:destroy-train xor-train)
(fann:destroy ann)
(fann:save ann "/tmp/xor-test.net")
(fann:destroy-train xor-train)
(fann:destroy ann)
```

Note that data is not fetched from file but from a list with the `fann:read-train-from-list` function.
Of course, you can still load data from files with `fann:read-train-from-file` as normal.

0 comments on commit 5a36fdd

Please sign in to comment.