I have a number of sequences stored in an 2D-array [[first_seq,first_seq],[first_seq,first_seq],[sec_seq,sec_seq]],..
.
Each vector-sequence varies in length.. some are 55 rows long others are 68 rows long.
The sequence 2D-array(features
) is shaped (427,227)
(, features) and I have another 1D-array(num_seq
) (5,)
which contains how long each sequence is [55,68,200,42,62]
(e.g. first seq is 55 rows long, sencond seq is 68 rows long etc.). len(1D-array) = number of seq
Now, I need each sequence to be equally long - namely each sequence to be 200. Since I have 5 sequences in this example the resulting array should be structured_seq = np.zeros(5,200,227)
If the sequence is shorter than 200 all other values of that sequence should be zero.
Therfore, I tried to fill structured_seq
doing something like:
for counter, sent in enumerate(num_seq):
for j, feat in enumerate(features):
if num_sent[counter] < 200:
structured_seq[counter,feat,]
but Im stuck..
So to be precise: The first sequence is the first 55 rows of the 2D-array(features
), all reamining 145 should be filled with zeros. And so on..