I figured it out that x.view(-1, 16 * 5 * 5)
is equivalent to x.flatten(1)
, where the parameter 1 indicates the flatten process starts from the 1st dimension(not flattening the 'sample' dimension)
As you can see, the latter usage is semantically more clear and easier to use, so I prefer flatten()
.