我不确定如何访问数组中的元素(数组?)。基本上,我需要能够为一系列数组分配随机数,但是我不确定索引的工作方式。
array_20 = np.zeros((5,10))
a = [[array_20]]*10
#This gives me 10 arrays of 5x10. I'd like to be able to then assign random
#numbers to all of the elements.
您可以像这样使用numpy.random.rand
:
numpy.random.rand
然后您可以像Python列表一样索引import numpy as np
a = np.random.rand(10, 5, 10)
。 (即a
)