customisable loss
This commit is contained in:
parent
63b328142a
commit
ef4ec5be4b
@ -7,7 +7,8 @@ initn(dims...) = randn(dims...)/100
|
|||||||
tobatch(xs::Batch) = rawbatch(xs)
|
tobatch(xs::Batch) = rawbatch(xs)
|
||||||
tobatch(xs) = tobatch(batchone(xs))
|
tobatch(xs) = tobatch(batchone(xs))
|
||||||
|
|
||||||
function train!(m, train, test = []; epoch = 1, η = 0.1)
|
function train!(m, train, test = [];
|
||||||
|
epoch = 1, η = 0.1, loss = mse)
|
||||||
i = 0
|
i = 0
|
||||||
for e in 1:epoch
|
for e in 1:epoch
|
||||||
info("Epoch $e")
|
info("Epoch $e")
|
||||||
@ -16,7 +17,7 @@ function train!(m, train, test = []; epoch = 1, η = 0.1)
|
|||||||
i += 1
|
i += 1
|
||||||
ŷ = m(x)
|
ŷ = m(x)
|
||||||
any(isnan, ŷ) && error("NaN")
|
any(isnan, ŷ) && error("NaN")
|
||||||
Δ = back!(mse, 1, ŷ, y)
|
Δ = back!(loss, 1, ŷ, y)
|
||||||
back!(m, Δ, x)
|
back!(m, Δ, x)
|
||||||
update!(m, η)
|
update!(m, η)
|
||||||
i % 1000 == 0 && @show accuracy(m, test)
|
i % 1000 == 0 && @show accuracy(m, test)
|
||||||
|
Loading…
Reference in New Issue
Block a user