In the MINST example of Flux Model Zoo, the layer that “flattens” tensor data before the Dense
layer uses reshape
:
# Reshape 3d tensor into a 2d one, at this point it should be (3, 3, 32, N)
# which is where we get the 288 in the `Dense` layer below:
x -> reshape(x, :, size(x, 4))
Is this the recommended way of flattening data batches in cases like this?
Or are there more efficient ways of doing it? (reshape
makes a copy of the data, which shouldn’t be necessary, I think.)