Flux.jl/src/layers/affine.jl

22 lines
326 B
Julia
Raw Normal View History

2016-11-14 22:16:00 +00:00
@net type Affine
2016-08-22 13:49:41 +00:00
W
b
2017-03-21 01:18:00 +00:00
x -> x*W .+ b
2016-08-22 13:49:41 +00:00
end
2016-11-14 22:16:00 +00:00
Affine(in::Integer, out::Integer; init = initn) =
Affine(init(in, out), init(1, out))
2017-03-17 16:34:51 +00:00
2017-06-12 11:39:34 +00:00
function back!(m::Affine, Δ, x)
W, b = m.W, m.b
W.Δx[:] = x' * Δ
b.Δx[:] = sum(Δ, 1)
Δ * W.x'
end
function update!(m::Affine, η)
update!(m.W, η)
update!(m.b, η)
m
2017-06-14 13:58:37 +00:00
end