NumPy reshape -1 meaning

The example given below will help you to understand the meaning of NumPy reshape -1. If you want to learn Python, I highly recommend reading This Book.

NumPy reshape -1 meaning
NumPy reshape -1 meaning
import numpy as np
a = np.array([[1,2,3], [4,5,6]])
print(a)

print(a.reshape(-1))

print(a.reshape(6,-1))

print(a.reshape(3,-1))

Output:

[[1 2 3]
 [4 5 6]]
[1 2 3 4 5 6]
[[1]
 [2]
 [3]
 [4]
 [5]
 [6]]
[[1 2]
 [3 4]
 [5 6]]

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.