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

DOC: LazyAdamOptimizer example #66

Merged
merged 11 commits into from
Mar 4, 2019

Conversation

seanpmorgan
Copy link
Member

@seanpmorgan seanpmorgan commented Mar 4, 2019

Simple example using LazyAdamOptimizer tested after installing the dev pip package. After we publish a 0.1 release we can install it in colab and have interactive examples.

@seanpmorgan seanpmorgan changed the title DOC: Example DOC: LazyAdamOptimizer example Mar 4, 2019
@seanpmorgan seanpmorgan closed this Mar 4, 2019
@seanpmorgan seanpmorgan reopened this Mar 4, 2019
@seanpmorgan
Copy link
Member Author

cc @karmel . Do you mind giving this a once over? I'd like to have a small example in the first release branch.

Going forward we'll strive for colab notebooks as well, and more interesting examples.

@seanpmorgan seanpmorgan requested a review from karmel March 4, 2019 20:22
@karmel
Copy link
Contributor

karmel commented Mar 4, 2019

@qlzh727 -- any chance you can take a look? I am unlikely to have time before the Dev Summit.

@qlzh727
Copy link
Member

qlzh727 commented Mar 4, 2019

Ack, I will take a quick look.

@seanpmorgan
Copy link
Member Author

Ah, sorry I forgot today is probably quite hectic. Probably doesn't need more than a glance its just MNIST with the LazyAdamOptimizer. I tested it and it converges fine

Copy link
Member

@qlzh727 qlzh727 left a comment

Choose a reason for hiding this comment

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

Thanks for the change. Mostly just python style comments.

tensorflow_addons/examples/tfa_optimizer.py Outdated Show resolved Hide resolved
:return: Keras `Model`
"""
inputs = tf.keras.Input(shape=(784,), name='digits')
net = tf.keras.layers.Dense(64, activation='relu', name='dense_1')(inputs)
Copy link
Member

Choose a reason for hiding this comment

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

Since this is just a sequential model, you can probably use keras.models.Sequential to get rid of "net". That said, this is purely optional, and depends on whether you want to show case the functional or sequential model.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I have no real preference, but feel that the functional form is more familiar to other frameworks.

tensorflow_addons/examples/tfa_optimizer.py Outdated Show resolved Hide resolved
tensorflow_addons/examples/tfa_optimizer.py Outdated Show resolved Hide resolved
tensorflow_addons/examples/tfa_optimizer.py Outdated Show resolved Hide resolved
tensorflow_addons/examples/tfa_optimizer.py Outdated Show resolved Hide resolved
tensorflow_addons/examples/tfa_optimizer.py Outdated Show resolved Hide resolved
validation_data=(data['x_val'], data['y_val']))

# Evaluate the network
print('\n# Evaluate on test data')
Copy link
Member

Choose a reason for hiding this comment

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

Just curious why it need the leading '\n'. Alternatively you can use tf.logging, which will print with same format as other TF logs generated during training.

Copy link
Member Author

Choose a reason for hiding this comment

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

All of the small implementation details were mostly copied from this:
https://github.com/tensorflow/docs/blob/master/site/en/r2/guide/keras/training_and_evaluation.ipynb

@seanpmorgan
Copy link
Member Author

@qlzh727 thanks for the review!

@seanpmorgan seanpmorgan merged commit 6d63531 into tensorflow:master Mar 4, 2019
@seanpmorgan seanpmorgan deleted the doc-examples branch March 4, 2019 22:25
Squadrick pushed a commit to Squadrick/addons that referenced this pull request Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants