numpy reshape 中的 -1 是什么意思? [英] What does -1 in numpy reshape mean?
本文介绍了numpy reshape 中的 -1 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have a numpy array (A) of shape = (100000, 28, 28)
I reshape it using A.reshape(-1, 28x28)
这在机器学习管道中非常常见.这是如何运作的 ?我一直不明白重塑中-1"的含义.
This is very common use in Machine learning pipelines. How does this work ? I have never understood the meaning of '-1' in reshape.
一个确切的问题是这个但没有确切的解释.任何答案请?
An exact question is this But no solid explanation. Any answers pls ?
推荐答案
这意味着,您通过 -1
传递的维度的大小正在被推断.因此,
It means, that the size of the dimension, for which you passed -1
, is being inferred. Thus,
A.reshape(-1, 28*28)
意思是重塑A
,使其第二维的尺寸为28*28,并计算出第一维的正确尺寸".
means, "reshape A
so that its second dimension has a size of 28*28 and calculate the correct size of the first dimension".
这篇关于numpy reshape 中的 -1 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文