simplify the implementation

This commit is contained in:
JohnnyChen 2019-04-05 18:44:00 +08:00
parent de7a5f4024
commit 3cafbbad02

View File

@ -42,19 +42,18 @@ end
# This is a temporary and naive inplementation # This is a temporary and naive inplementation
# it might be replaced in the future to get better performance
# see issue https://github.com/FluxML/Flux.jl/issues/702 # see issue https://github.com/FluxML/Flux.jl/issues/702
# Johnny Chen -- @johnnychen94
""" """
activations(c::Chain, x) activations(c::Chain, input)
Calculate the forward results of each layers in Chain `c` Calculate the forward results of each layers in Chain `c` with `input` as model input.
""" """
function activations(c::Chain, x) function activations(c::Chain, input)
rst = Array{Any,1}() rst = []
if isempty(c) for l in c
return rst x = get(rst, length(rst), input)
end push!(rst, l(x))
push!(rst, c[1](x))
for l in c[2:end]
push!(rst, l(rst[end]))
end end
return rst return rst
end end