fix(train): fix an error in computing layer's error
feat(examples): add an example (xor)
This commit is contained in:
BIN
app/Main.hi
BIN
app/Main.hi
Binary file not shown.
17
app/Main.hs
17
app/Main.hs
@ -9,19 +9,16 @@ import Debug.Trace
|
||||
-- 2x3 + 1x3
|
||||
-- 3x1 + 1x1
|
||||
|
||||
main :: IO ()
|
||||
-- main :: IO [()]
|
||||
main =
|
||||
let learning_rate = 0.01
|
||||
ih = randomLayer 0 (2, 10)
|
||||
ho = randomLayer 1 (10, 1)
|
||||
let learning_rate = 0.5
|
||||
ih = randomLayer 0 (2, 8)
|
||||
ho = randomLayer 1 (8, 1)
|
||||
network = ih :- O ho
|
||||
inputs = [vector [0, 1], vector [1, 1], vector [1, 0], vector [0, 0]]
|
||||
|
||||
-- result = forward input network
|
||||
inputs = [vector [0, 1], vector [1, 0], vector [1, 1], vector [0, 0]]
|
||||
labels = [vector [1], vector [1], vector [0], vector [0]]
|
||||
|
||||
labels = [vector [1], vector [0], vector [1], vector [0]]
|
||||
|
||||
updated_network = session inputs network labels learning_rate 100
|
||||
-- updated_network = train (head inputs) network (head labels) 0.5
|
||||
updated_network = session inputs network labels learning_rate (2, 1000)
|
||||
results = map (`forward` updated_network) inputs
|
||||
in print results
|
||||
|
BIN
app/Main.o
BIN
app/Main.o
Binary file not shown.
Reference in New Issue
Block a user