What does -1 mean in numpy reshape?
问题 A numpy matrix can be reshaped into a vector using reshape function with parameter -1. But I don't know what -1 means here. For example: a = numpy.matrix([[1, 2, 3, 4], [5, 6, 7, 8]]) b = numpy.reshape(a, -1) The result of b is: matrix([[1, 2, 3, 4, 5, 6, 7, 8]]) Does anyone know what -1 means here? And it seems python assign -1 several meanings, such as: array[-1] means the last element. Can you give an explanation? 回答1: The criterion to satisfy for providing the new shape is that 'The new