A 2D array can be reshaped into a 1D array using .reshape(-1)
.
For example:
>>> a = numpy.array([[1, 2, 3, 4], [5, 6, 7, 8]])
>>> a.reshape(-1)
array([[1, 2, 3, 4, 5, 6, 7, 8]])
Usually, array[-1]
means the last element.
But what does -1 mean here?