Convert a list to an 3 dimensional numpy array

Viewed 391

I have a list, which consist collection of differently shaped 2 dimensional numpy arrays inside it. It looks like this.

enter image description here

My goal is to convert this to a 3d numpy array so that its structure is something like this

[ 
  [[ ]
   [ ]
    :
     ],

  [[ ]
   [ ]
    :
     ],

    :
]

or in words

[

 two dimensional array 1,
 two dimensional array 2,
 two dimensional array 3,
       :
       :
]

I tried doing

arr = np.array(garbage)

that gives me an array but it is not structured as I described it. Its shape comes out to be (40336,)

I have to pass the array to a RNN. Do I have to pad zeros for all internal 2 dimensional arrays so that they are of same shape which will make the outer array of the three dimensional shape that I want?

0 Answers
Related