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