How to transform a 4-D Tensor (1,1,2040,1) to a numpy 1-d array of 2040?


l have 4-D tensor variable (1,1,2040,1) that l want to covert to a numpy 1-D vector of dim(2040)

l tried


but it gives me a 4-d numpy array (1,1,2040,1)

Thank you

I suppose image is your Tensor?

image = image.numpy().ravel()
1 Like

Try image.squeeze().numpy(), if the image is a tensor

1 Like