mardi 13 juin 2017

How to assign values of a 2d array to 3d array in NumPy

I'm currently working on a 3d array called X of size (100,5,1). I want to assign the randomly created 2d arrays called s, dimension of (5,1) to X. My code is like below.

for i in range(100):
    s = np.random.uniform(-1, 2, 5) 
    for j in range(5):
        X[:,j,:] = s[j]

I got 100 (5,1) arrays and they're all the same. I can see why I have this result, but I can't find the solution for this.

I need to have 100 unique (5,1) arrays in X.




Aucun commentaire:

Enregistrer un commentaire