-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recurrent layer to treat 2nd and the rest of inputs as initial_states #7691
Recurrent layer to treat 2nd and the rest of inputs as initial_states #7691
Conversation
aef0616
to
9601c67
Compare
tests/keras/layers/recurrent_test.py
Outdated
initial_state = [np.random.random((num_samples, units)) | ||
for _ in range(num_states)] | ||
targets = np.random.random((num_samples, units)) | ||
model.fit([main_inputs] + initial_state, targets) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use train_on_batch
to make the test lighter. Similarly I suggest you use 2
instead of num_samples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching to train_on_batch
, but num_samples
is already defined as 2 at the beginning of the file, isn't it.
tests/test_model_saving.py
Outdated
@keras_test | ||
def test_saving_recurrent_layer_with_init_state(): | ||
VECTOR_SIZE = 8 | ||
INPUT_LENGTH = 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for all caps variable names here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing to lower case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
I believe |
I've never used the class. If you are not hurry, I may look into it this weekend. |
…github.com:dschwertfeger/keras into tensorboard-callback-embeddings-from-layer-outputs * 'tensorboard-callback-embeddings-from-layer-outputs' of github.com:dschwertfeger/keras: Update for PPM format (keras-team#7750) Style fix Style fix Prepare 2.0.8 release. Update TFRecord example. Update backend docs. Style fix. Update README.md and setup.py. Minor optimizer consistency fixes. Recurrent layer to treat 2nd and the rest of inputs as initial_states (keras-team#7691) added 2 missing scripts to the README in the examples folder (keras-team#7734) Fixes and tests wrt step-wise training. Fix PEP8 (keras-team#7731) fix image_ocr example steps_per_epoch and validation_steps params (keras-team#7696) Remove requirement that batch_size divides len(x_train) in Variational Autoencoders examples. (keras-team#7716) Small fixes in training.py
Hi. I'm submitting a PR for a bug reported in #7612.
I think the Recurrent layer should treat a part of the inputs as
initial_states
. I think this is also what you want to do according to the API doc. If you have a different design, please suggest.