matrix = np.array([[10,450],[110,250],[200,500]])
reshaped = matrix.reshape(-1,1,2)
How will the matrix be reshaped? And what is the meaning of (-1,1,2)?
matrix = np.array([[10,450],[110,250],[200,500]])
reshaped = matrix.reshape(-1,1,2)
How will the matrix be reshaped? And what is the meaning of (-1,1,2)?
There are 3 arguments in the reshape, so the result will be a 3-dimensional array.
The 2nd dimension will have size 1, the 3rd dimension size 2.
The -1
for the 1st dimension means that the size of this 1st dimension is calculated on-the-fly, such that all the elements nicely fit.
In this specific case, the result is therefore
array([[[ 10, 450]],
[[110, 250]],
[[200, 500]]])