Flux Chain function

Why does the Chain function not warn if the output of one layer is not compatible with the imput of the next?

Chain can take arbitrary functions. Given that, how would you check the inputs/outputs of the following are compatible?

f1(x) = sum(x, dims=1)
function f2(x)
  ndims(x) == 1 && error("too few dims")
  return x .+ 1
end

c = Chain(f1, f2)

Without actually calling c, there is no way to know whether you’ll get a size mismatch. Thankfully, Flux provides a way to do this and get inferred output sizes without having to run a full forward pass of your model. See outputsize.