-
Notifications
You must be signed in to change notification settings - Fork 617
Adds TQDMProgressBar in callbacks #610
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
99f1071
import files and added new tutorial
shun-lin c4d8858
Update tqdm_progress_bar.ipynb
shun-lin 3c774e1
update ipynb notebook and py
shun-lin 16b9ae7
final update before pull request
shun-lin 3d41365
fix typo!
shun-lin 2b48c68
fix styling
shun-lin a9b7950
Added demo image to tutorial, fixed addons/callbacks README, clean ou…
shun-lin 5996166
added TQDMProgressBar to readme.md in callback
shun-lin 6ac11a3
added try catch for import tqdm, add version of tqdm on tutorial, add…
shun-lin 1ab1181
put the import inside __init__ and check version
shun-lin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
{ | ||
shun-lin marked this conversation as resolved.
Show resolved
Hide resolved
shun-lin marked this conversation as resolved.
Show resolved
Hide resolved
shun-lin marked this conversation as resolved.
Show resolved
Hide resolved
shun-lin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"##### Copyright 2019 The TensorFlow Authors." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n", | ||
"# you may not use this file except in compliance with the License.\n", | ||
"# You may obtain a copy of the License at\n", | ||
"#\n", | ||
"# https://www.apache.org/licenses/LICENSE-2.0\n", | ||
"#\n", | ||
"# Unless required by applicable law or agreed to in writing, software\n", | ||
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n", | ||
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", | ||
"# See the License for the specific language governing permissions and\n", | ||
"# limitations under the License." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# TensorFlow Addons Callbacks: TQDM Progress Bar" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n", | ||
" <td>\n", | ||
" <a target=\"_blank\" href=\"https://www.tensorflow.org/addons/tutorials/tqdm_progress_bar\"><img src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" />View on TensorFlow.org</a>\n", | ||
" </td>\n", | ||
" <td>\n", | ||
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/addons/blob/master/docs/tutorials/tqdm_progresss_bar.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n", | ||
" </td>\n", | ||
" <td>\n", | ||
" <a target=\"_blank\" href=\"https://github.com/tensorflow/addons/blob/master/docs/tutorials/tqdm_progress_bar.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n", | ||
" </td>\n", | ||
" <td>\n", | ||
" <a href=\"https://storage.googleapis.com/tensorflow_docs/docs/docs/tutorials/tqdm_progress_bar.ipynb\"><img src=\"https://www.tensorflow.org/images/download_logo_32px.png\" />Download notebook</a>\n", | ||
" </td>\n", | ||
"</table>" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Overview\n", | ||
"This notebook will demonstrate how to use TQDMCallback in TensorFlow Addons." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Setup" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"!pip install -q tqdm>=4.36.1\n", | ||
"\n", | ||
"!pip install -q ipywidgets\n", | ||
"!pip install -q --no-deps tensorflow-addons~=0.6\n", | ||
"!jupyter nbextension enable --py widgetsnbextension --sys-prefix" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"try:\n", | ||
" # %tensorflow_version only exists in Colab.\n", | ||
" %tensorflow_version 2.x\n", | ||
"except Exception:\n", | ||
" pass" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import tensorflow as tf\n", | ||
"import tensorflow_addons as tfa\n", | ||
"\n", | ||
"import tensorflow.keras as keras\n", | ||
"from tensorflow.keras.datasets import mnist\n", | ||
"from tensorflow.keras.models import Sequential\n", | ||
"from tensorflow.keras.layers import Dense, Dropout, Flatten" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Import and Normalize Data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# the data, split between train and test sets\n", | ||
"(x_train, y_train), (x_test, y_test) = mnist.load_data()\n", | ||
"# normalize data\n", | ||
"x_train, x_test = x_train / 255.0, x_test / 255.0" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Build Simple MNIST CNN Model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# build the model using the Sequential API\n", | ||
"model = Sequential()\n", | ||
"model.add(Flatten(input_shape=(28, 28)))\n", | ||
"model.add(Dense(128, activation='relu'))\n", | ||
"model.add(Dropout(0.2))\n", | ||
"model.add(Dense(10, activation='softmax'))\n", | ||
"\n", | ||
"model.compile(optimizer='adam',\n", | ||
" loss = 'sparse_categorical_crossentropy',\n", | ||
" metrics=['accuracy'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Default TQDMCallback Usage" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# initialize tqdm callback with default parameters\n", | ||
"tqdm_callback = tfa.callbacks.TQDMProgressBar()\n", | ||
"\n", | ||
"# train the model with tqdm_callback\n", | ||
"# make sure to set verbose = 0 to disable\n", | ||
"# the default progress bar.\n", | ||
"model.fit(x_train, y_train,\n", | ||
" batch_size=64,\n", | ||
" epochs=10,\n", | ||
" verbose=0,\n", | ||
" callbacks=[tqdm_callback],\n", | ||
" validation_data=(x_test, y_test))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"**Below is the expected output when you run the cell above**\n", | ||
"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,12 @@ | |
## Maintainers | ||
| Submodule | Maintainers | Contact Info | | ||
|:---------- |:------------- |:--------------| | ||
| | | | | ||
| tqdm_progress_bar | @shun-lin | [email protected] | | ||
|
||
## Contents | ||
| Submodule | Metric | Reference | | ||
| Submodule | Callback | Reference | | ||
|:----------------------- |:-------------------|:---------------| | ||
| | | | | ||
| tqdm_progress_bar | TQDMProgressBar | https://tqdm.github.io/ | | ||
|
||
|
||
## Contribution Guidelines | ||
|
@@ -21,7 +21,7 @@ must: | |
* Add the addon to the `py_library` in this sub-package's BUILD file. | ||
|
||
#### Testing Requirements | ||
* Simple unittests that demonstrate the metric is behaving as expected. | ||
* Simple unittests that demonstrate the callback is behaving as expected. | ||
* When applicable, run all unittests with TensorFlow's | ||
`@run_in_graph_and_eager_modes` (for test method) | ||
or `run_all_in_graph_and_eager_modes` (for TestCase subclass) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.