deal with empty Chain

This commit is contained in:
dsweber2 2019-09-10 10:46:56 -07:00
parent 1bb25dc1f9
commit f41219133e

View File

@ -52,9 +52,11 @@ Calculate the forward results of each layers in Chain `c` with `input` as model
""" """
function activations(c::Chain, input) function activations(c::Chain, input)
res = Zygote.Buffer([], length(c)) res = Zygote.Buffer([], length(c))
res[1] = c[1](input) if length(c) > 0
for (i,l) in enumerate(c[2:end]) res[1] = c[1](input)
res[i+1] = l(res[i]) for (i,l) in enumerate(c[2:end])
res[i+1] = l(res[i])
end
end end
return copy(res) return copy(res)
end end