Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'tuple' object cannot be interpreted as an integer

I have x0 which is a float64 (64,64) array. Whenever I try this:

    delta = np.random.randn(x0.shape)

It gives the captioned error. This is so basic that I'm wrapping my heads around it. What am I missing out? Thanks

The complete traceback is as follows:

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
like image 974
srkdb Avatar asked Dec 03 '22 11:12

srkdb


1 Answers

np.random.randn() requires integer arguments, in the form randn(64,64). You are giving np.random.randn() arguments in the form randn((64,64)), which it is not expecting. Instead, if you want to build a 64x64 random array, you will need to pass the number of rows and columns individually, not as a tuple.

like image 118
R Balasubramanian Avatar answered Dec 27 '22 20:12

R Balasubramanian