update recurrent usage
This commit is contained in:
parent
224d84691d
commit
ad6e6b4116
|
@ -4,7 +4,7 @@ export Recurrent, GatedRecurrent, LSTM
|
|||
Wxy; Wyy; by
|
||||
y
|
||||
function (x)
|
||||
y = tanh( x * Wxy + y * Wyy + by )
|
||||
y = tanh( x * Wxy + y{-1} * Wyy + by )
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -17,10 +17,10 @@ Recurrent(in, out; init = initn) =
|
|||
Wxh; Wyh; bh
|
||||
y
|
||||
function (x)
|
||||
reset = σ( x * Wxr + y * Wyr + br )
|
||||
update = σ( x * Wxu + y * Wyu + bu )
|
||||
y′ = tanh( x * Wxh + (reset .* y) * Wyh + bh )
|
||||
y = (1 .- update) .* y′ + update .* y
|
||||
reset = σ( x * Wxr + y{-1} * Wyr + br )
|
||||
update = σ( x * Wxu + y{-1} * Wyu + bu )
|
||||
y′ = tanh( x * Wxh + (reset .* y{-1}) * Wyh + bh )
|
||||
y = (1 .- update) .* y′ + update .* y{-1}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,12 +36,12 @@ GatedRecurrent(in, out; init = initn) =
|
|||
y; state
|
||||
function (x)
|
||||
# Gates
|
||||
forget = σ( x * Wxf + y * Wyf + bf )
|
||||
input = σ( x * Wxi + y * Wyi + bi )
|
||||
output = σ( x * Wxo + y * Wyo + bo )
|
||||
forget = σ( x * Wxf + y{-1} * Wyf + bf )
|
||||
input = σ( x * Wxi + y{-1} * Wyi + bi )
|
||||
output = σ( x * Wxo + y{-1} * Wyo + bo )
|
||||
# State update and output
|
||||
state′ = tanh( x * Wxc + y * Wyc + bc )
|
||||
state = forget .* state + input .* state′
|
||||
state′ = tanh( x * Wxc + y{-1} * Wyc + bc )
|
||||
state = forget .* state{-1} + input .* state′
|
||||
y = output .* tanh(state)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue