Open FriendOfFatBeagle opened 6 years ago
https://keras.io/getting-started/sequential-model-guide/
The model needs to know what input shape it should expect. For this reason, the first layer in a Sequential model (and only the first, because following layers can do automatic shape inference) needs to receive information about its input shape. There are several possible ways to do this:
**Pass an input_shape argument to the first layer.**
....
Hi birolkuyumcu:
You did not answer my question. Seems like you do not understand my question.
## Repeat:
My question refers to this code: model.add(layers.GRU(32, input_shape=(None, float_data.shape[-1])))
When I looked up documentation for layers.GRU(), at https://keras.io/layers/recurrent/#gru, there is no documentation for argument input_shape. There is no mention of input-shape argument. The same problem also occurs with layers.LSTM(). This makes learning very hard.
.... ....
See the rest in original post.
Why is argument input_shape not listed as one of the many arguments of LSTM() and GRU() at https://keras.io/layers/recurrent/#lstm and at https://keras.io/layers/recurrent/#gru ?
How do I go about locating specific information on all arguments that are used by these classes if I cannot find them in recurrent.py?
https://github.com/keras-team/keras/blob/master/keras/engine/topology.py#L279
note that 'dtype', 'input_shape' and 'batch_input_shape' are only applicable to input layers
Hi Birol:
Thank you. I have NO idea input_shape argument is declared in file topoloty.py located in folder: `> ~/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/engine $ ls
init.py pycache topology.py training.py `
What steps did you take to locate it in topology.py?
The only place I knew how to look was in layers folder, like so:
> ~/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/layers $ ls advanced_activations.py core.py local.py normalization.py recurrent.py convolutional.py embeddings.py merge.py pooling.py wrappers.py convolutional_recurrent.py __init__.py noise.py __pycache__
Addendum:
I see there is a reference to importing Layer from engine folder in file init.py in
folder, ~/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/layers
Is the above folder and init,py is how you locate reference for input-shape argument or is there some other more efficient way?
By the way, input-shape is listed as one of many arguments in
https://www.tensorflow.org/api_docs/python/tf/keras/layers/GRU and https://www.tensorflow.org/api_docs/python/tf/keras/layers/LSTM
Inconsistency and missing information in keras documentation is just rampant or I may just do not have adequate knowledge of how to locate appropriate reference. Any instructions on how to efficiently do so would greatly accelerate learning.
Thank you, again.
Layer is a abstract base class of all layers so All layers inherited it how to find ? https://github.com/keras-team/keras/blob/master/keras/layers/recurrent.py#L16 then https://github.com/keras-team/keras/blob/master/keras/engine/__init__.py#L6
i think sequential model guide explain input_shape argument maybe explanation about this at about keras layers makes more clear https://keras.io/layers/about-keras-layers/
Hi Birol:
Thank you. Below has good explanation (mostly via code samples) on how to specify input_shape for RNN/GRU/LStM:
https://keras.io/layers/recurrent/ RNN ; Base class for recurrent layers.
Input shape 3D tensor with shape (batch_size, timesteps, input_dim).
Hi Birol:
Google translate: Çok yardımcı oldun. Cömert zamanınız için teşekkür ederiz. of "You have been very helpful. Thank you for your generous time." Sorry, I do not speak your native tongue.
Hi Everybody:
I am using Keras 2.0.5. Here are code samples for section 6.3 of book, "Advanced use of recurrent neural network" pertaining to GRU:
`from keras.models import Sequential from keras import layers from keras.optimizers import RMSprop
model = Sequential() model.add(layers.GRU(32, input_shape=(None, float_data.shape[-1]))) model.add(layers.Dense(1))
model.compile(optimizer=RMSprop(), loss='mae') history = model.fit_generator(train_gen, steps_per_epoch=500, epochs=20, validation_data=val_gen, validation_steps=val_steps)`
My question refers to this code: model.add(layers.GRU(32, input_shape=(None, float_data.shape[-1])))
When I looked up documentation for layers.GRU(), at https://keras.io/layers/recurrent/#gru, there is no documentation for argument input_shape. There is no mention of input-shape argument. The same problem also occurs with layers.LSTM(). This makes learning very hard.
I also tried looking at the source code, for class Recurrent(Layer) and class GRU(Recurrent) in recurrent.py for Keras 2.0.5, input_shape does not seems to exists as an argument for these classes!
What did I missed?
Why is argument input_shape not listed as one of the many arguments of LSTM() and GRU() at https://keras.io/layers/recurrent/#lstm and at https://keras.io/layers/recurrent/#gru ?
How do I go about locating specific information on all arguments that are used by these classes?
Thank you.