How to reshape a NumPy array into a vector in Python

An arbitrary dimension NumPy array with n elements can be reshaped into a one-dimensional vector of length n. For example, [[0 1 2] [3 4 5]] reshaped as a vector is [0 1 2 3 4 5 6].

Solution for How to reshape a NumPy array into a vector in Python : You can use numpy.reshape() to reshape a NumPy array into a vector Use numpy.reshape(array, newshape) with -1 as newshape to reshape array into a vector.


how-to-reshape-a-numpy-array-into-a-vector-in-python