Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeInnes committed Sep 12, 2017
1 parent 568869b commit f205273
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/layers/stateless.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
mse(ŷ, y) = sum((ŷ .- y).^2)/length(y)
# back!(::typeof(mse), Δ, ŷ, y) = Δ .* (ŷ .- y)

logloss(ŷ, y) = -sum(y .* log.(ŷ))
logloss(ŷ, y) = -sum(y .* log.(ŷ)) / size(y, 2)
# back!(::typeof(logloss), Δ, ŷ, y) = 0 .- Δ .* y ./ ŷ
5 changes: 4 additions & 1 deletion src/optimise/optimisers.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
function descent(p::Param, η::Real)
() -> p.x .-= p.Δ .* η
function ()
p.x .-= p.Δ .* η
p.Δ .= 0
end
end

function momentum(p::Param, ρ::Real)
Expand Down
5 changes: 4 additions & 1 deletion src/optimise/train.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ tocb(fs::AbstractVector) = () -> foreach(call, fs)
function train!(m, data, opt; cb = () -> ())
cb = tocb(cb)
@progress for x in data
back!(m(x...))
l = m(x...)
isinf(l.data[]) && error("Inf")
isnan(l.data[]) && error("NaN")
back!(l)
opt()
cb()
end
Expand Down

0 comments on commit f205273

Please sign in to comment.