【发布时间】:2017-06-06 04:56:01
【问题描述】:
I have a numpy array (A) of shape = (100000, 28, 28)
I reshape it using A.reshape(-1, 28x28)
这在机器学习管道中非常常见。 这是如何运作的 ?我从来没有理解重塑中'-1'的含义。
一个确切的问题是this 但没有可靠的解释。请问有什么答案吗?
【问题讨论】:
-
查看文档:docs.scipy.org/doc/numpy/reference/generated/… -
The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions. -
在您的示例中,生成的数组将具有形状 (100000, 784)。它是第一维的简写,因为只有一个值是正确的。
标签: python numpy machine-learning