deal with empty Chain
This commit is contained in:
parent
1bb25dc1f9
commit
f41219133e
@ -52,10 +52,12 @@ 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))
|
||||||
|
if length(c) > 0
|
||||||
res[1] = c[1](input)
|
res[1] = c[1](input)
|
||||||
for (i,l) in enumerate(c[2:end])
|
for (i,l) in enumerate(c[2:end])
|
||||||
res[i+1] = l(res[i])
|
res[i+1] = l(res[i])
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return copy(res)
|
return copy(res)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user