r/Numpy•
samketa

What does this code mean when flattening a rank-4 tensor?

I am trying to reshape an image to a vector to pass it as an input to a neuron.

Normally I would flatten a rank-4 tensor using-

arr.reshape(shape_x * shape_y * channels, 1)

I saw this being done as-

arr.reshape(arr.shape[0], -1).T

I know what the shape[0] returns, what the .T does, but I have no idea about the -1. What does that mean and what role does it play here?

Posted Oct 18, 2020, 12:57 PM UTC

44
Loading comments…