我有一个名为x0的float64(64,64)数组。每当我尝试这样做:
delta = np.random.randn(x0.shape)
出现了上述错误。问题非常基础,我也感到困惑。我错过了什么?谢谢。
完整的回溯信息如下:
Traceback (most recent call last):
File "<ipython-input-31-dcd2365ed519>", line 1, in <module>
delta = np.random.randn(x0.shape)
File "mtrand.pyx", line 1420, in mtrand.RandomState.randn
File "mtrand.pyx", line 1550, in mtrand.RandomState.standard_normal
File "mtrand.pyx", line 167, in mtrand.cont0_array
TypeError: 'tuple' object cannot be interpreted as an integer
type(x0.shape)
是什么? - MoxieBall*
:np.random.randn(*x0.shape)
。 - John Coleman