reshape and -1
reshape changes the shape without changing data. -1 means work out this size.
Example
a = np.arange(12)
print(a.reshape(3, 4))
print(a.reshape(2, -1).shape)
print(a.reshape(2, 3, 2).shape)Result
[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] (2, 6) (2, 3, 2)
Exercise
Infer a size.
a.reshape(2, )
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.