Skip to content Skip to sidebar Skip to footer

Deep Learning (lstm) With Keras And Variable Size Of Inputs

I am trying to implement a lstm model with keras. The problem is that I have data of different shapes. My data looks like this: col1 col2 col3 col4 col5 [1,2,3] [2,3,4] [3,4,5]

Solution 1:

A multidimensional numpy array need have a clear shape so putting array of different length inside the same numpy array will result in a numpy array of objects instead odf the desired multidimension array.

So basically it's not possible to feed your data to keras in one go.

However there are several possible solutions. Most of them require that your keras input shape has to be None in your timestep dimension:

  1. Use padding that your data always has the same shape
  2. train with batch_size = 1
  3. Sort your data in batches in a way that inside each batch every sample has the same shape.

The last two options require the usage of the fit_generator option, because you have to feed the data step wise.

Post a Comment for "Deep Learning (lstm) With Keras And Variable Size Of Inputs"