美文网首页
np.reshape 中的 -1 参数

np.reshape 中的 -1 参数

作者: LabVIEW_Python | 来源:发表于2021-01-14 07:59 被阅读0次

numpy.reshape(a, newshape, order='C') newshape: int or tuple of ints
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.
参考 https://numpy.org/doc/stable/reference/generated/numpy.reshape.html#numpy-reshape

意思是:新形状newshape中,有一个维度可以填写-1, -1的意思是:-1 表示这个维度的值是从x的元素总数和剩余维度推断出来的。因此,有且只有一个维度可以被设置为-1

np.reshape -1范例

相关文章

网友评论

      本文标题:np.reshape 中的 -1 参数

      本文链接:https://www.haomeiwen.com/subject/juguaktx.html