Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

-1 in numpy reshape

import numpy as np

# 2 X 3 matrix = 6 items
arr = np.array([[1, 2, 3], [4, 5, 6]])

# reshaping a matrix with -1 will let the function know that this dimension is not currently know
# x X 1 = 6 => x = 6
# therefore, by the end of this function, the new output will be 6 X 1 matrix
arr.reshape(-1, 1)
 
PREVIOUS NEXT
Tagged: #numpy #reshape
ADD COMMENT
Topic
Name
5+3 =