Skip to content
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

Model() yield op Input internal fixes, plus add K.is_placeholder() #7046

Closed
wants to merge 76 commits into from

Conversation

ahundt
Copy link
Contributor

@ahundt ahundt commented Jun 20, 2017

These changes include K.is_placeholder(), plus the internal changes of #6928, excluding the labels parameter or TFRecord support. This includes better checks to prevent data from being fed to feed_dict or fetches incorrectly during model.run(), improved user input sanity checks, and simplified backend function initialization.

Please also consider my alternative external API proposals in #6928 (comment), but that should be kept separate from these internal improvements.

ahundt added 30 commits June 12, 2017 18:42
…ted labels.

mnist_tfrecord.py training runs correctly
…hen lists are empty and the learning phase is True
… crash when lists are empty and the learning phase is True"

This reverts commit b7ea15f.
@ahundt
Copy link
Contributor Author

ahundt commented Jun 21, 2017

only failure was flaky test #7033, closing and reopening

@ahundt ahundt closed this Jun 21, 2017
@ahundt ahundt reopened this Jun 21, 2017
Copy link
Contributor

@Dref360 Dref360 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring of training.py! I love it!
The addition of yield is also nice and could be useful.
Maybe add a FAQ bullet for this behaviour? Otherwise, noboby will know about it :( .
Otherwise LGTM (beside some comments)

@@ -27,7 +27,8 @@

def _standardize_input_data(data, names, shapes=None,
check_batch_axis=True,
exception_prefix=''):
exception_prefix='',
tensors=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc

loss=None,
metrics=['accuracy'])

tensorboard = TensorBoard(write_graph=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless?

Copy link
Contributor Author

@ahundt ahundt Jun 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to disable it because without the expected_targets param, (I'd like to rename it to that from labels) much of Keras' functionality is broken in this use case. Passing callbacks=[tensorboard] crashes. It runs perfectly in #6928, with limited functionality with this PR, and not at all on master...

y_train_in_out = Input(tensor=y_train_batch, batch_shape=y_batch_shape, name='y_labels')
cce = categorical_crossentropy(y_train_batch, x_train_out)
train_model = Model(inputs=[x_train_input], outputs=[x_train_out])
train_model.add_loss(cce)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a lot of people knew about this trick. Really nice!

Copy link
Contributor Author

@ahundt ahundt Jun 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

credit: @fchollet in #6928

However, it is extremely limiting, a good portion of the functionality enabled by model.compile() is skipped... see below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally I've discovered this trick has serious performance problems, see #7075 (comment). It is 20x slower than mnist_tfrecord.py in #6928

@ahundt
Copy link
Contributor Author

ahundt commented Jun 21, 2017

I've split this up into many smaller PRs, the capstone change is #7072 which should link to all the smaller ones.

@ahundt ahundt mentioned this pull request Jun 21, 2017
@ahundt
Copy link
Contributor Author

ahundt commented Jun 24, 2017

This PR has been superseded by #6928 because of #7102 (comment). For that reason I'm closing this PR.

@ahundt ahundt closed this Jun 24, 2017
ahundt added a commit to ahundt/keras that referenced this pull request Aug 1, 2017
…ut_data

* is_placeholder:
  K.is_placeholder() becomes simple member variable is_placeholder with getattr checks
  remove extraneous imports of is_placeholder
  extra is_placeholder() tests
  is_placeholder theano_backend.py
  test is_placeholder()
  is_placeholder() implemented small part of keras-team#6928 and keras-team#7046
ahundt added a commit to ahundt/keras that referenced this pull request Aug 5, 2017
* mnist_tfrecord:
  mnist_tfrecord.py
  loss defaults to None in compile()
  lower batch size and epochs
  mnist_tfrecord.py indentation fix
  mnist_tfrecord.py add parallelism option
  mnist_tfrecord.py pep8
  Fix mnist_tfrecord.py runtime errors
  mnist_tfrecord.py added (keras-team#7061, keras-team#7072, keras-team#6928, keras-team#7046)
ahundt added a commit to ahundt/keras that referenced this pull request Aug 5, 2017
* fit_steps_per_epoch:
  removed extraneous line
  mnist_tfrecord.py add coordinator
  mnist_tfrecord.py fix key missing lines
  mnist_tfrecord.py
  loss defaults to None in compile()
  lower batch size and epochs
  mnist_tfrecord.py indentation fix
  mnist_tfrecord.py add parallelism option
  mnist_tfrecord.py pep8
  Fix mnist_tfrecord.py runtime errors
  mnist_tfrecord.py added (keras-team#7061, keras-team#7072, keras-team#6928, keras-team#7046)

# Conflicts:
#	examples/mnist_tfrecord.py
ahundt added a commit to ahundt/keras that referenced this pull request Aug 5, 2017
…support added

* standardize_input_data:
  replace is_placeholder with is_keras_placeholder to resolve conflict with cntk backend (keras-team#7067) keras-team#7067 (comment)
  training.py _standardize_input_data() accounts for input tensors (keras-team#7067)
  fix _feed_inputs name
  _standardize_input_data() now only standardizes data that is convertible to numpy array based on what is destined for the feed_dict
  _standardize_input_data accepts feed inputs
  _standardize_input_data add missing space to exception error string
  K.is_placeholder() becomes simple member variable is_placeholder with getattr checks
  remove extraneous imports of is_placeholder
  extra is_placeholder() tests
  is_placeholder theano_backend.py
  test is_placeholder()
  is_placeholder() implemented small part of keras-team#6928 and keras-team#7046

# Conflicts:
#	keras/engine/topology.py
#	keras/engine/training.py
fchollet pushed a commit that referenced this pull request Aug 11, 2017
* generic_utils.py don't crash when dealing with batched data

* Progbar() unit test

* mnist_tfrecord.py added (#7061, #7072, #6928, #7046)

* Fix mnist_tfrecord.py runtime errors

* mnist_tfrecord.py pep8

* mnist_tfrecord.py add parallelism option

* reorder inputs

* mnist_tfrecord.py indentation fix

* lower batch size and epochs

* loss defaults to None in compile()

* mnist_tfrecord.py

* model.fit(steps_per_epoch) added

* added _check_num_samples for cases when batch_size does not apply

* fix test failures

* remove inaccurate warning

* improved fit(steps_per_epoch) with separate internal epoch loop in _fit_loop

* fit(steps_per_epoch) initial validation support

* training.py pep8

* mnist_tfrecord.py fix key missing lines

* mnist_tfrecord.py add coordinator

* removed extraneous line

* mnist_tfrecord.py and training.py clean up based on review (#7113)

* mnist_tfrecord.py extended description

* training.py fix test error

* mnist_tfrecord.py and training.py fixed review comments, docs, and error messages (#7113)

* training.py fix unit test error for steps_per_epoch

* fix docstring comments from review (#7113)

* training.py improve docstrings and error case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants