Monday, 27 August 2018

How to interpret clearly the meaning of the units parameter in Keras?

I am wondering how LSTM work in Keras. In this tutorial for example, as in many others, you can find something like this :

model.add(LSTM(4, input_shape=(1, look_back)))

What does the "4" mean. Is it the number of neuron in the layer. By neuron, I mean something that for each instance gives a single output ?

Actually, I found this brillant discussion but wasn't really convinced by the explanation mentioned in the reference given.

On the scheme, one can see the num_unitsillustrated and I think I am not wrong in saying that each of this unit is a very atomic LSTM unit (i.e. the 4 gates). However, how these units are connected ? If I am right (but not sure), x_(t-1)is of size nb_features, so each feature would be an input of a unit and num_unit must be equal to nb_features right ?

Now, let's talk about keras. I have read this post and the accepted answer and get trouble. Indeed, the answer says :

Basically, the shape is like (batch_size, timespan, input_dim), where input_dim can be different from the unit

In which case ? I am in trouble with the previous reference...

Moreover, it says,

LSTM in Keras only define exactly one LSTM block, whose cells is of unit-length.

Okay, but how do I define a full LSTM layer ? Is it the input_shape that implicitely create as many blocks as the number of time_steps (which, according to me is the first parameter of input_shape parameter in my piece of code ?

Thanks for lighting me



from How to interpret clearly the meaning of the units parameter in Keras?

No comments:

Post a Comment