numpy's reshape is a method that transforms a multidimensional array by specifying a numerical value, but if you use -1, you only need to specify one numerical value and the method will automatically do not specify the other numerical value. Will decide the numerical value.
An example of making a list of 3 elements into a 1-by-3 matrix
arr = [1,2,3]
print(len(arr))
# 3
narr1 = np.array(arr).reshape(1,3)
print(narr1.shape)
# (1, 3)
narr2 = np.array(arr).reshape(1,-1)
print(narr2.shape)
# (1, 3)
Recommended Posts