lundi 8 novembre 2021

How to input a 1-D array of dimensions into numpy.random.randn?

Say I have a 1-D array dims:

dims = np.array((1,2,3,4))

I want to create a n-th order normally distributed tensor where n is the size of the dims and dims[i] is the size of the i-th dimension.

I tried to do

A = np.random.randn(dims)

But this doesn't work. I could do

A = np.random.randn(1,2,3,4)

which would work but n can be large and n can be random in itself. How can I read in a array of the size of the dimensions in this case?




Aucun commentaire:

Enregistrer un commentaire