From aa6b76c166fe9c660a965f28d90d9ed188556cd8 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Sun, 8 Sep 2019 20:49:08 -0400 Subject: [PATCH 1/6] Initial setup for tensorflow subsite --- .gitignore | 3 --- docs/_book.yaml | 46 ++++++++++++++++++++++++++++++++++++ docs/_index.yaml | 58 ++++++++++++++++++++++++++++++++++++++++++++++ docs/_project.yaml | 26 +++++++++++++++++++++ 4 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 docs/_book.yaml create mode 100644 docs/_index.yaml create mode 100644 docs/_project.yaml diff --git a/.gitignore b/.gitignore index 03daca4818..13536a41b3 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,3 @@ wheels/ /.bazelrc /bazel-* /artifacts - -# Addons -/docs/ diff --git a/docs/_book.yaml b/docs/_book.yaml new file mode 100644 index 0000000000..95b8e54610 --- /dev/null +++ b/docs/_book.yaml @@ -0,0 +1,46 @@ +# Copyright 2019 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== +upper_tabs: + # Tabs left of dropdown menu + - include: /_upper_tabs_left.yaml + - include: /api_docs/_upper_tabs_api.yaml + # Dropdown menu + - name: Resources + path: /resources + is_default: true + menu: + - include: /resources/_menu_toc.yaml + lower_tabs: + # Subsite tabs + other: + - name: Examples + contents: + - title: Triplet Loss + path: /addons/examples/losses_triplet + - title: Image Ops + path: /addons/examples/image_ops + - title: Normalization Layers + path: /addons/examples/layers_normalizations + - title: Weight Normalization Layer + path: /addons/examples/layers_weightnormalization + - title: LazyAdam Optimizer + path: /addons/examples/optimizers_lazyadam + - name: API + skip_translation: true + contents: + - include: /addons/api_docs/python/_toc.yaml + + - include: /_upper_tabs_right.yaml \ No newline at end of file diff --git a/docs/_index.yaml b/docs/_index.yaml new file mode 100644 index 0000000000..f7f50a36f8 --- /dev/null +++ b/docs/_index.yaml @@ -0,0 +1,58 @@ +# Copyright 2019 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== +book_path: /addons/_book.yaml +project_path: /addons/_project.yaml +description: +landing_page: + custom_css_path: /site-assets/css/style.css + rows: + - heading: TensorFlow Addons provides useful extra functionality for TensorFlow 2.0 maintained by SIG-addons + items: + - classname: devsite-landing-row-50 + description: > + TensorFlow Addons is a repository of contributions that conform to + well-established API patterns, but implement new functionality + not available in core TensorFlow. TensorFlow natively supports + a large number of operators, layers, metrics, losses, and + optimizers. However, in a fast moving field like ML, there are many + interesting new developments that cannot be integrated into core + TensorFlow (because their broad applicability is not yet clear, or + it is mostly used by a smaller subset of the community). + code_block: | +
+            import tensorflow as tf
+            import tensorflow_addons as tfa
+            # This is a short code snippet that shows off your project.
+            # Launch a Colab notebook to run this example.
+            print("Hello, PROJECT_NAME")
+            
+ {% dynamic if request.tld != 'cn' %} + Run in a Notebook + {% dynamic endif %} + - classname: devsite-landing-row-cards + items: + - heading: "Introducing TensorFlow Addons" + image_path: /resources/images/tf-logo-card-16x9.png + path: https://medium.com/tensorflow/introducing-tensorflow-addons-6131a50a3dcf + buttons: + - label: "Read on TensorFlow blog" + path: https://medium.com/tensorflow/introducing-tensorflow-addons-6131a50a3dcf + - heading: "TensorFlow Addons on GitHub" + image_path: /resources/images/github-card-16x9.png + path: https://github.com/tensorflow/addons + buttons: + - label: "View on GitHub" + path: https://github.com/tensorflow/addons \ No newline at end of file diff --git a/docs/_project.yaml b/docs/_project.yaml new file mode 100644 index 0000000000..4b267aa101 --- /dev/null +++ b/docs/_project.yaml @@ -0,0 +1,26 @@ +# Copyright 2019 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== +name: TensorFlow Addons +breadcrumb_name: Addons +home_url: /addons/ +parent_project_metadata_path: /_project.yaml +description: > + "TensorFlow Addons is a library of useful extra functionality for + TensorFlow 2.0 maintained by SIG-addons" +use_site_branding: true +hide_from_products_list: true +content_license: cc-apache +include: /_project_included.yaml \ No newline at end of file From 18a632735206495a059945bda6b6f1b4f4194c20 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Mon, 9 Sep 2019 10:36:55 -0400 Subject: [PATCH 2/6] Add examples to pip package --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 66661736de..f66c17f566 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ recursive-include tensorflow_addons/ *.so +include examples/*.ipynb \ No newline at end of file From a7d32e084a515fce661770832894b11c6cc727b6 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Tue, 10 Sep 2019 12:05:11 -0400 Subject: [PATCH 3/6] Move examples and rename as tutorials --- CONTRIBUTING.md | 4 ++-- MANIFEST.in | 2 +- docs/_book.yaml | 12 ++++++------ {examples => docs/tutorials}/README.md | 8 ++++---- {examples => docs/tutorials}/image_ops.ipynb | 4 ++-- .../tutorials}/layers_normalizations.ipynb | 4 ++-- .../tutorials}/layers_weightnormalization.ipynb | 4 ++-- {examples => docs/tutorials}/losses_triplet.ipynb | 4 ++-- .../tutorials}/optimizers_lazyadam.ipynb | 4 ++-- {examples => docs/tutorials}/template.ipynb | 4 ++-- 10 files changed, 25 insertions(+), 25 deletions(-) rename {examples => docs/tutorials}/README.md (73%) rename {examples => docs/tutorials}/image_ops.ipynb (99%) rename {examples => docs/tutorials}/layers_normalizations.ipynb (97%) rename {examples => docs/tutorials}/layers_weightnormalization.ipynb (98%) rename {examples => docs/tutorials}/losses_triplet.ipynb (97%) rename {examples => docs/tutorials}/optimizers_lazyadam.ipynb (95%) rename {examples => docs/tutorials}/template.ipynb (96%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3aae3caf1f..30b7f9f790 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,9 +17,9 @@ let us give you advice on the proposed changes. If the changes are minor, then feel free to make them without discussion. Want to contribute but not sure of what? Here are a few suggestions: -1. Add a new example or tutorial. Located in [`examples/`](examples), +1. Add a new tutorial. Located in [`docs/turoials/`](docs/tutorials), these are a great way to familiarize yourself and others with TF-Addons. See - [the guidelines](examples/README.md) for more information on how to add + [the guidelines](docs/tutorials/README.md) for more information on how to add examples. 2. Solve an [existing issue](https://github.com/tensorflow/addons/issues). These range from low-level software bugs to higher-level design problems. diff --git a/MANIFEST.in b/MANIFEST.in index f66c17f566..6115caf2b3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ recursive-include tensorflow_addons/ *.so -include examples/*.ipynb \ No newline at end of file +include docs/* \ No newline at end of file diff --git a/docs/_book.yaml b/docs/_book.yaml index 95b8e54610..5154e632e5 100644 --- a/docs/_book.yaml +++ b/docs/_book.yaml @@ -26,18 +26,18 @@ upper_tabs: lower_tabs: # Subsite tabs other: - - name: Examples + - name: tutorials contents: - title: Triplet Loss - path: /addons/examples/losses_triplet + path: /addons/tutorials/losses_triplet - title: Image Ops - path: /addons/examples/image_ops + path: /addons/tutorials/image_ops - title: Normalization Layers - path: /addons/examples/layers_normalizations + path: /addons/tutorials/layers_normalizations - title: Weight Normalization Layer - path: /addons/examples/layers_weightnormalization + path: /addons/tutorials/layers_weightnormalization - title: LazyAdam Optimizer - path: /addons/examples/optimizers_lazyadam + path: /addons/tutorials/optimizers_lazyadam - name: API skip_translation: true contents: diff --git a/examples/README.md b/docs/tutorials/README.md similarity index 73% rename from examples/README.md rename to docs/tutorials/README.md index 2ef0869976..8145d2512c 100644 --- a/examples/README.md +++ b/docs/tutorials/README.md @@ -1,18 +1,18 @@ -# TensorFlow Addons Examples +# TensorFlow Addons Tutorials -TensorFlow Addons welcomes and highly encourages example contributions. +TensorFlow Addons welcomes and highly encourages tutorial contributions. ## How To Contribute -Addons examples are created using [Google Colab](https://colab.research.google.com/) +Addons tutorials are created using [Google Colab](https://colab.research.google.com/) and the jupyter notebooks are saved to this directory in the repository. To do this, follow the below steps: 1. Create a new branch on your fork of TensorFlow Addons 2. Goto [Google Colab](https://colab.research.google.com/) and start a new notebook using addons example template: -[examples/template.ipynb](template.ipynb) +[docs/tutorials/template.ipynb](template.ipynb) 3. Edit the the links for the "View source on GitHub" and "Run in Google Colab" URL boxes so that they match the name of your new example notebook 4. Follow the guidelines of the template diff --git a/examples/image_ops.ipynb b/docs/tutorials/image_ops.ipynb similarity index 99% rename from examples/image_ops.ipynb rename to docs/tutorials/image_ops.ipynb index 51e1a93908..b254f7f672 100644 --- a/examples/image_ops.ipynb +++ b/docs/tutorials/image_ops.ipynb @@ -59,10 +59,10 @@ "\n", "\n", " \n", " \n", "
\n", - " Run in Google Colab\n", + " Run in Google Colab\n", " \n", - " View source on GitHub\n", + " View source on GitHub\n", "
" ] diff --git a/examples/layers_normalizations.ipynb b/docs/tutorials/layers_normalizations.ipynb similarity index 97% rename from examples/layers_normalizations.ipynb rename to docs/tutorials/layers_normalizations.ipynb index 7eb91dccb5..918470563b 100644 --- a/examples/layers_normalizations.ipynb +++ b/docs/tutorials/layers_normalizations.ipynb @@ -61,10 +61,10 @@ "\n", "\n", " \n", " \n", "
\n", - " Run in Google Colab\n", + " Run in Google Colab\n", " \n", - " View source on GitHub\n", + " View source on GitHub\n", "
\n" ] diff --git a/examples/layers_weightnormalization.ipynb b/docs/tutorials/layers_weightnormalization.ipynb similarity index 98% rename from examples/layers_weightnormalization.ipynb rename to docs/tutorials/layers_weightnormalization.ipynb index ce572e883d..ca815f0f7e 100644 --- a/examples/layers_weightnormalization.ipynb +++ b/docs/tutorials/layers_weightnormalization.ipynb @@ -61,10 +61,10 @@ "\n", "\n", " \n", " \n", "
\n", - " Run in Google Colab\n", + " Run in Google Colab\n", " \n", - " View source on GitHub\n", + " View source on GitHub\n", "
" ] diff --git a/examples/losses_triplet.ipynb b/docs/tutorials/losses_triplet.ipynb similarity index 97% rename from examples/losses_triplet.ipynb rename to docs/tutorials/losses_triplet.ipynb index 82f27ba18b..add8e744a6 100644 --- a/examples/losses_triplet.ipynb +++ b/docs/tutorials/losses_triplet.ipynb @@ -61,10 +61,10 @@ "\n", "\n", " \n", " \n", "
\n", - " Run in Google Colab\n", + " Run in Google Colab\n", " \n", - " View source on GitHub\n", + " View source on GitHub\n", "
" ] diff --git a/examples/optimizers_lazyadam.ipynb b/docs/tutorials/optimizers_lazyadam.ipynb similarity index 95% rename from examples/optimizers_lazyadam.ipynb rename to docs/tutorials/optimizers_lazyadam.ipynb index d77e652ab9..c42b8f5069 100644 --- a/examples/optimizers_lazyadam.ipynb +++ b/docs/tutorials/optimizers_lazyadam.ipynb @@ -61,10 +61,10 @@ "\n", "\n", " \n", " \n", "
\n", - " Run in Google Colab\n", + " Run in Google Colab\n", " \n", - " View source on GitHub\n", + " View source on GitHub\n", "
" ] diff --git a/examples/template.ipynb b/docs/tutorials/template.ipynb similarity index 96% rename from examples/template.ipynb rename to docs/tutorials/template.ipynb index 8e22d9d2c8..61e414269a 100644 --- a/examples/template.ipynb +++ b/docs/tutorials/template.ipynb @@ -71,10 +71,10 @@ "source": [ "\n", " \n", " \n", "
\n", - " Run in Google Colab\n", + " Run in Google Colab\n", " \n", - " View source on GitHub\n", + " View source on GitHub\n", "
" ] From 2a3578b4bf570d91c5bb4a0ce36e2108395319bf Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Tue, 10 Sep 2019 12:05:20 -0400 Subject: [PATCH 4/6] Update example code --- docs/_index.yaml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/_index.yaml b/docs/_index.yaml index f7f50a36f8..ad6e7727e2 100644 --- a/docs/_index.yaml +++ b/docs/_index.yaml @@ -35,12 +35,31 @@ landing_page:
             import tensorflow as tf
             import tensorflow_addons as tfa
-            # This is a short code snippet that shows off your project.
-            # Launch a Colab notebook to run this example.
-            print("Hello, PROJECT_NAME")
+
+            # Load MNIST dataset as NumPy arrays
+            dataset = {}
+            num_validation = 10000
+            (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
+
+            # Preprocess the data
+            x_train = x_train.reshape(-1, 784).astype('float32') / 255
+            x_test = x_test.reshape(-1, 784).astype('float32') / 255
+
+            # Compile the model
+            model.compile(
+                optimizer=tfa.optimizers.LazyAdam(0.001),  # Utilize TFA optimizer
+                loss=tf.keras.losses.SparseCategoricalCrossentropy(),
+                metrics=['accuracy'])
+
+            # Train the network
+            history = model.fit(
+                x_train,
+                y_train,
+                batch_size=24,
+                epochs=10)
             
{% dynamic if request.tld != 'cn' %} - Run in a Notebook + Run in a Notebook {% dynamic endif %} - classname: devsite-landing-row-cards items: From 5a36b514de13413fd3be449e950305701aaa4bbc Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Tue, 10 Sep 2019 13:23:53 -0400 Subject: [PATCH 5/6] Spelling and style --- CONTRIBUTING.md | 2 +- docs/_book.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30b7f9f790..ec08372228 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ let us give you advice on the proposed changes. If the changes are minor, then feel free to make them without discussion. Want to contribute but not sure of what? Here are a few suggestions: -1. Add a new tutorial. Located in [`docs/turoials/`](docs/tutorials), +1. Add a new tutorial. Located in [`docs/tutorials/`](docs/tutorials), these are a great way to familiarize yourself and others with TF-Addons. See [the guidelines](docs/tutorials/README.md) for more information on how to add examples. diff --git a/docs/_book.yaml b/docs/_book.yaml index 5154e632e5..6de538db84 100644 --- a/docs/_book.yaml +++ b/docs/_book.yaml @@ -28,15 +28,15 @@ upper_tabs: other: - name: tutorials contents: - - title: Triplet Loss + - title: Triplet loss path: /addons/tutorials/losses_triplet - title: Image Ops path: /addons/tutorials/image_ops - - title: Normalization Layers + - title: Normalization layers path: /addons/tutorials/layers_normalizations - - title: Weight Normalization Layer + - title: Weight normalization layer path: /addons/tutorials/layers_weightnormalization - - title: LazyAdam Optimizer + - title: Lazyadam optimizer path: /addons/tutorials/optimizers_lazyadam - name: API skip_translation: true From 00e91db3b644b0b5e064f58a1345953cf1886e25 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Tue, 17 Sep 2019 15:14:24 -0400 Subject: [PATCH 6/6] Update README to use the word `tutorials` --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ecabd4ae65..ef4e747c2a 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,8 @@ bazel-bin/build_pip_pkg artifacts pip install artifacts/tensorflow_addons-*.whl ``` -## Examples -See [`examples/`](examples/) +## Tutorials +See [`docs/tutorials/`](docs/tutorials/) for end-to-end examples of various addons. ## Core Concepts