diff --git a/.github/workflows/bot-label-lgtm.yaml b/.github/workflows/bot-label-lgtm.yaml deleted file mode 100644 index 27f50375cdc..00000000000 --- a/.github/workflows/bot-label-lgtm.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow adds the community approval label ("lgtm") to pull requests. It -# does *not* indicate maintainer approval. This a way to visually highlight that -# someone in the world thinks the pull request is ready for further review. This -# event is triggered by a pull request approval, or simply a comment that -# contains the text "lgtm". -# Webhook events: Issue comments, Pull request reviews -name: Community approval -on: - repository_dispatch: - # From: issue_comment, pull_request_review - types: [created, edited, submitted] - -jobs: - lgtm-comment: - # Check the comment. contains() is case-insensitive. - if: >- - ${{ github.actor == 'tfdocsbot' && - contains(github.event.client_payload.comment.body, 'LGTM') }} - runs-on: ubuntu-latest - steps: - - name: Add label - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ISSUE_URL: ${{ github.event.client_payload.comment.issue_url }} - run: | - curl -X POST \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - "${ISSUE_URL}/labels" \ - --data '{"labels":["lgtm"]}' - - review-approval: - # Check the pull request review. - if: >- - ${{ github.actor == 'tfdocsbot' && - contains(github.event.client_payload.review.state, 'approved') }} - runs-on: ubuntu-latest - steps: - - name: Add label - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ISSUE_URL: ${{ github.event.client_payload.pull_request.issue_url }} - run: | - curl -X POST \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - "${ISSUE_URL}/labels" \ - --data '{"labels":["lgtm"]}' diff --git a/.github/workflows/bot-nightly.yaml b/.github/workflows/bot-nightly.yaml deleted file mode 100644 index a0595c74a0b..00000000000 --- a/.github/workflows/bot-nightly.yaml +++ /dev/null @@ -1,65 +0,0 @@ -# Nightly jobs run by a bot collaborator. -name: Nightly jobs -on: - repository_dispatch: - types: [nightly] - -jobs: - snapshot-source: - name: Update Keras guides - if : ${{ github.actor == 'tfdocsbot' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - repository: keras-team/keras-io - path: keras-io - - uses: actions/checkout@v2 - with: - # tensorflow/docs branch to save generated notebooks. - ref: snapshot-keras - path: docs - - name: Set up repo - run: | - # Set commit author. - git config --global user.name "$GITHUB_ACTOR" - git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.8' - - name: Install requirements - run: | - python3 -m pip install -U pip - python3 -m pip install -U -r keras-io/requirements.txt - python3 -m pip install -U git+https://github.com/tensorflow/docs - - name: Generate Keras notebooks - run: | - # Autogen requires formated code - echo "[${GITHUB_WORKFLOW}] Format Python files ..." - python -m black keras-io/guides/ - mkdir -p keras-io/tf # Make sure output dir exists. - cd keras-io/scripts/ - echo "[${GITHUB_WORKFLOW}] Generate Keras guides ..." - python3 autogen.py generate_tf_guides - echo "[${GITHUB_WORKFLOW}] Format notebooks ..." - python3 -m tensorflow_docs.tools.nbfmt ../tf/ - - name: Sync docs repo - env: - KERAS_GUIDES_DIR: site/en/guide/keras/ - run: | - rsync --archive --del --checksum ./keras-io/tf/ "./docs/${KERAS_GUIDES_DIR}" - cd docs - if [[ -z $(git status -s | grep "$KERAS_GUIDES_DIR") ]]; then - echo "[${GITHUB_WORKFLOW}] No Keras guides updated, exiting." - exit 0 - fi - # Match timestamp format to other snapshot messages. - fmt_rfc7231="%a, %d %b %Y %H:%M:%S %Z" - TIMESTAMP_STR=$(TZ=GMT date +"$fmt_rfc7231") - - git add "./${KERAS_GUIDES_DIR}" - git commit -m "Keras guides snapshot: ${TIMESTAMP_STR}" - # Push to current branch. - echo "[${GITHUB_WORKFLOW}] Push changes to repo ..." - git push origin diff --git a/.github/workflows/bot-pr-fix.yaml b/.github/workflows/bot-pr-fix.yaml deleted file mode 100644 index a8ead3aa7ae..00000000000 --- a/.github/workflows/bot-pr-fix.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# Automatically add commits to fix pull requests. This workflow must initiate -# from an authenticated bot repo collaborator. Check for opt-out label. -# Webhook events: Pull requests -name: Auto-fix pull request -on: - repository_dispatch: - types: [opened, synchronize] - -jobs: - nbfmt: - # Check for opt-out label. - if: >- - ${{ github.actor == 'tfdocsbot' && - !contains(github.event.client_payload.pull_request.labels.*.name, 'nbfmt-disable') }} - runs-on: ubuntu-latest - steps: - - name: Set up Python - uses: actions/setup-python@v2 - - name: Install tensorflow-docs - run: python3 -m pip install -U git+https://github.com/tensorflow/docs - - name: Fetch pull request branch - uses: actions/checkout@v2 - with: - # Head repo is the user's fork. Ref is the branch name. - repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} - ref: ${{ github.event.client_payload.pull_request.head.ref }} - - name: Fetch base master branch - run: git fetch -u "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" master:master - - name: Format notebooks - run: | - # Only want notebooks modified in this pull request. - readarray -t changed_files < <(git diff --name-only master | grep '\.ipynb$' || true) - if [[ ${#changed_files[@]} == 0 ]]; then - echo "No notebooks modified in this pull request." - exit 0 - fi - python3 -m tensorflow_docs.tools.nbfmt "${changed_files[@]}" - - if [[ -z $(git ls-files --modified) ]]; then - echo "Notebooks already formatted." - exit 0 - fi - # Set author and commit. - git config --global user.name "$GITHUB_ACTOR" - git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" - git commit -am "nbfmt" - # Push to the pull request branch submitted by head. - git push diff --git a/.github/workflows/bot-pr-new.yaml b/.github/workflows/bot-pr-new.yaml index 7f2c6164832..13724cc14f0 100644 --- a/.github/workflows/bot-pr-new.yaml +++ b/.github/workflows/bot-pr-new.yaml @@ -6,8 +6,15 @@ on: repository_dispatch: types: [opened, reopened] +permissions: + contents: read # to fetch code (actions/checkout) + jobs: comment-welcome: + permissions: + contents: read # to fetch code (actions/checkout) + pull-requests: write # to comment on pull-request + if: ${{ github.actor == 'tfdocsbot' }} runs-on: ubuntu-latest steps: @@ -15,7 +22,7 @@ jobs: uses: actions/checkout@v2 with: repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} - ref: ${{ github.event.client_payload.pull_request.head.ref }} + ref: ${{ github.event.client_payload.pull_request.head.sha }} - name: Fetch base master branch run: git fetch -u "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" master:master - name: Create message diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml new file mode 100644 index 00000000000..0ca76b0677e --- /dev/null +++ b/.github/workflows/stale.yaml @@ -0,0 +1,49 @@ +# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. +# +# You can adjust the behavior by modifying this file. +# For more information, see: +# https://github.com/actions/stale +name: Mark stale issues and pull requests + +on: + schedule: + # Scheduled to run at 1.30 UTC everyday + - cron: '30 1 * * *' + workflow_dispatch: + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v9 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-issue-stale: 14 + days-before-issue-close: 14 + stale-issue-label: "status:stale" + close-issue-reason: not_planned + any-of-labels: "awaiting-contributor-response,cla:no" + stale-issue-message: > + Marking this issue as stale since it has been open for 14 days with no activity. + This issue will be closed if no further activity occurs. + close-issue-message: > + This issue was closed because it has been inactive for 28 days. + Please post a new issue if you need further assistance. Thanks! + days-before-pr-stale: 14 + days-before-pr-close: 14 + stale-pr-label: "status:stale" + stale-pr-message: > + Marking this pull request as stale since it has been open for 14 days with no activity. + This PR will be closed if no further activity occurs. + close-pr-message: > + This pull request was closed because it has been inactive for 28 days. + Please open a new pull request if you need further assistance. Thanks! + # Label that can be assigned to issues to exclude them from being marked as stale + exempt-issue-labels: 'override-stale' + # Label that can be assigned to PRs to exclude them from being marked as stale + exempt-pr-labels: "override-stale" diff --git a/CODEOWNERS b/CODEOWNERS index 42fd773cab2..d4d2932d8bc 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,11 +1,14 @@ # https://help.github.com/articles/about-codeowners/ -# Last matching pattern takes preecedence. +# Last matching pattern takes precedence. # Default owners for everything in repo. -* @lamberta @MarkDaoust @8bitmp3 +* @tensorflow/docs-team -# Docs -/site/en/guide/keras/ @fchollet @lamberta @MarkDaoust @8bitmp3 +# Install +/site/en/install/ @haifeng-jin @MarkDaoust @8bitmp3 # Community -/site/en/community/ @ewilderj @lamberta @theadactyl @joanafilipa +/site/en/community/ @ewilderj @theadactyl @joanafilipa + +# Hub +/site/en/hub @gustheman \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1559b721f51..6f301eab782 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,9 +6,7 @@ This guide shows how to make contributions to [tensorflow.org](https://www.tenso See the [TensorFlow docs contributor guide](https://www.tensorflow.org/community/contribute/docs) -for guidance. For questions, the -[docs@tensorflow.org](https://groups.google.com/a/tensorflow.org/forum/#!forum/docs) -mailing list is available. +for guidance. For questions, check out [TensorFlow Forum](https://discuss.tensorflow.org/). Questions about TensorFlow usage are better addressed on [Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow) or the diff --git a/LICENSE b/LICENSE index 4862420c023..08026f1ac8e 100644 --- a/LICENSE +++ b/LICENSE @@ -201,3 +201,28 @@ Copyright 2018 The TensorFlow Authors. All rights reserved. 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. + + +--------------------------- + +Where indicated, some files are also distributed under the MIT License: + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index fa4266dd2dc..c3f79ccabe2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ -recursive-include tools/tensorflow_docs/api_generator/gen_java/ * \ No newline at end of file +global-include **/templates/* +global-include *.sh \ No newline at end of file diff --git a/OWNERS_METADATA b/OWNERS_METADATA deleted file mode 100644 index 1460eaaba9e..00000000000 --- a/OWNERS_METADATA +++ /dev/null @@ -1,20 +0,0 @@ -# Text proto format: devtools_piper.OwnersMetadataFile (go/owners_metadata) -# See go/silos-lite for details on how to use this file for read access control. -silo_acl { - # Acknowledgement that silo won't contain privacy sensitive data, like PII. - silo_will_contain_privacy_sensitive_data: false - - # This retains normal access for regular engineers and other accounts. - access_type: OPEN - - # This is equivalent to above. Currently, default_ganpati_group is a - # mandatory field in SiloAcl. We plan to make it optional in case - # access_type is OPEN. - default_ganpati_group: "piper-group-default-access" - - # Ganpati1 groups that are granted *read* access in addition to the default - # group above. - allowed_ganpati_groups: "restricted-dev-build" - allowed_ganpati_groups: "job-0000396906033-webdevelopmentdevelopermarketingwebprojects" - allowed_ganpati_groups: "job-0000551608589-smetechnicalwriterii" -} diff --git a/README.md b/README.md index 7b94ce5f90f..66b6d3fb065 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ To file a docs issue, use the issue tracker in the [tensorflow/tensorflow](https://github.com/tensorflow/tensorflow/issues/new?template=20-documentation-issue.md) repo. And join the TensorFlow documentation contributors on the -[docs@tensorflow.org mailing list](https://groups.google.com/a/tensorflow.org/forum/#!forum/docs). +[TensorFlow Forum](https://discuss.tensorflow.org/). ## Community translations diff --git a/setup.py b/setup.py index 2077516bf4c..404479668b3 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ # ============================================================================== """tensorflow_docs is a package for generating python api-reference docs.""" +import datetime import subprocess import sys @@ -21,22 +22,35 @@ from setuptools import setup project_name = 'tensorflow-docs' -version = '0.0.0.dev0' + + +def get_version() -> str: + ts = int( + subprocess.check_output(['git', 'log', '-1', '--format=%ct', 'tools']) + .decode('utf-8') + .strip() + ) + dt = datetime.datetime.utcfromtimestamp(ts) + sec = 60 * 60 * dt.hour + 60 * dt.minute + dt.second + + # calver.org + return f'{dt.year}.{dt.month}.{dt.day}.{sec}' + + +version = get_version() DOCLINES = __doc__.split('\n') REQUIRED_PKGS = [ 'astor', 'absl-py', - 'protobuf>=3.14', + 'jinja2', + 'nbformat', + 'protobuf>=3.12', 'pyyaml', ] -# Dataclasses is in-built from py >=3.7. This version is a backport for py 3.6. -if (sys.version_info.major, sys.version_info.minor) == (3, 6): - REQUIRED_PKGS.append('dataclasses') - -VIS_REQURE = [ +VIS_REQUIRE = [ 'numpy', 'PILLOW', 'webp', @@ -45,6 +59,7 @@ # https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords setup( name=project_name, + python_requires='>=3.9', version=version, description=DOCLINES[0], long_description='\n'.join(DOCLINES[2:]), @@ -57,7 +72,7 @@ package_dir={'': 'tools'}, scripts=[], install_requires=REQUIRED_PKGS, - extras_require={'vis': VIS_REQURE}, + extras_require={'vis': VIS_REQUIRE}, classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', @@ -65,7 +80,7 @@ 'Topic :: Scientific/Engineering :: Artificial Intelligence', ], keywords='tensorflow api reference', - # Include_package_data is required for setup.py to recognize the MAINFEST.in + # Include_package_data is required for setup.py to recognize the MANIFEST.in # https://python-packaging.readthedocs.io/en/latest/non-code-files.html include_package_data=True, ) diff --git a/site/en/README.md b/site/en/README.md new file mode 100644 index 00000000000..28dc0cce7d4 --- /dev/null +++ b/site/en/README.md @@ -0,0 +1,50 @@ +# TensorFlow docs + +These are the source files for the core TensorFlow +[guide](https://www.tensorflow.org/guide), +[tutorials](https://www.tensorflow.org/tutorials), and other technical docs. +Please read the +[contributor guide](https://www.tensorflow.org/community/contribute) +to submit patches to the TensorFlow documentation and code. + +## TensorFlow ecosystem projects + +In addition to the core TensorFlow docs, +[tensorflow.org](https://www.tensorflow.org) hosts documentation for many +[libraries and extensions](https://www.tensorflow.org/resources/libraries-extensions). +These docs are sourced from separate project repos and where pull requests can +be sent. The following is a list of TensorFlow documentation projects published +on the website and a link to their source files: + +tensorflow.org project | GitHub docs location +-----------------------|--------------------- +[/addons](https://www.tensorflow.org/addons) | https://github.com/tensorflow/addons/tree/master/docs +[/agents](https://www.tensorflow.org/agents) | https://github.com/tensorflow/agents/tree/master/docs +[/cloud](https://www.tensorflow.org/cloud) | https://github.com/tensorflow/cloud/tree/master/g3doc +[/datasets](https://www.tensorflow.org/datasets) | https://github.com/tensorflow/datasets/tree/master/docs +[/decision_forests](https://www.tensorflow.org/decision_forests) | https://github.com/tensorflow/decision-forests/tree/main/documentation +[/federated](https://www.tensorflow.org/federated) | https://github.com/tensorflow/federated/tree/main/docs +[/graphics](https://www.tensorflow.org/graphics) | https://github.com/tensorflow/graphics/tree/master/tensorflow_graphics/g3doc +[/hub](https://www.tensorflow.org/hub) | https://github.com/tensorflow/hub/tree/master/docs +[/io](https://www.tensorflow.org/io) | https://github.com/tensorflow/io/tree/master/docs/ +[/js](https://www.tensorflow.org/js) | https://github.com/tensorflow/tfjs-website/tree/master/docs +[/jvm](https://www.tensorflow.org/jvm) | https://github.com/tensorflow/java/tree/master/docs +[/lattice](https://www.tensorflow.org/lattice) | https://github.com/tensorflow/lattice/tree/master/docs +[/lite](https://www.tensorflow.org/lite) | https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/g3doc +[/mlir](https://www.tensorflow.org/mlir) | https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/g3doc +[/model_optimization](https://www.tensorflow.org/model_optimization) | https://github.com/tensorflow/model-optimization/tree/master/tensorflow_model_optimization/g3doc +[/neural_structured_learning](https://www.tensorflow.org/neural_structured_learning) | https://github.com/tensorflow/neural-structured-learning/tree/master/g3doc +[/probability](https://www.tensorflow.org/probability) | https://github.com/tensorflow/probability/tree/main/tensorflow_probability/g3doc +[/quantum](https://www.tensorflow.org/quantum) | https://github.com/tensorflow/quantum/tree/master/docs +[/ranking](https://www.tensorflow.org/ranking) | https://github.com/tensorflow/ranking/tree/master/docs +[/recommenders](https://www.tensorflow.org/recommenders) | https://github.com/tensorflow/recommenders/tree/main/docs +[/responsible_ai/fairness_indicators](https://www.tensorflow.org/responsible_ai/fairness_indicators/guide) | https://github.com/tensorflow/fairness-indicators/tree/master/g3doc +[/responsible_ai/model_card_toolkit](https://www.tensorflow.org/responsible_ai/model_card_toolkit/guide) | https://github.com/tensorflow/model-card-toolkit/tree/main/model_card_toolkit/documentation +[/responsible_ai/model_remediation](https://www.tensorflow.org/responsible_ai/model_remediation) | https://github.com/tensorflow/model-remediation/tree/master/docs +[/responsible_ai/privacy](https://www.tensorflow.org/responsible_ai/privacy/guide) | https://github.com/tensorflow/privacy/tree/master/g3doc +[/tensorboard](https://www.tensorflow.org/tensorboard) | https://github.com/tensorflow/tensorboard/tree/master/docs +[/guide/keras](https://www.tensorflow.org/guide/keras/) | https://github.com/keras-team/keras-io/tree/master/guides +[/text](https://www.tensorflow.org/text) | https://github.com/tensorflow/text/tree/master/docs +[/tfx](https://www.tensorflow.org/tfx) | https://github.com/tensorflow/tfx/tree/master/docs +[/tfx/guide/serving](https://www.tensorflow.org/tfx/guide/serving) | https://github.com/tensorflow/serving/tree/master/tensorflow_serving/g3doc +[/xla](https://www.tensorflow.org/xla) | https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/xla/g3doc diff --git a/site/en/about/_menu_toc.yaml b/site/en/about/_menu_toc.yaml index d5fe88d3745..8f34ca8089d 100644 --- a/site/en/about/_menu_toc.yaml +++ b/site/en/about/_menu_toc.yaml @@ -5,5 +5,3 @@ toc: path: /about/ - label: "Case studies" path: /about/case-studies/ - - label: "AI Service Partners" - path: /partners/ diff --git a/site/en/about/bib.md b/site/en/about/bib.md index a45eec3a40c..16da75adc3e 100644 --- a/site/en/about/bib.md +++ b/site/en/about/bib.md @@ -43,7 +43,7 @@ title={ {TensorFlow}: Large-Scale Machine Learning on Heterogeneous Systems}, url={https://www.tensorflow.org/}, note={Software available from tensorflow.org}, author={ - Mart\'{\i}n~Abadi and + Mart\'{i}n~Abadi and Ashish~Agarwal and Paul~Barham and Eugene~Brevdo and diff --git a/site/en/addons/README.md b/site/en/addons/README.md deleted file mode 100644 index 3f0ca09e73f..00000000000 --- a/site/en/addons/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Welcome to the warp zone! - -# TensorFlow SIG Addons - -These docs are available here: https://github.com/tensorflow/addons/tree/master/docs diff --git a/site/en/agents/README.md b/site/en/agents/README.md deleted file mode 100644 index 468efd02dcd..00000000000 --- a/site/en/agents/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Welcome to the warp zone! - -# TensorFlow Agents - -These docs are available here: https://github.com/tensorflow/agents/tree/master/docs diff --git a/site/en/community/_toc.yaml b/site/en/community/_toc.yaml index 074ecf72531..1a81d38cb01 100644 --- a/site/en/community/_toc.yaml +++ b/site/en/community/_toc.yaml @@ -34,5 +34,7 @@ toc: - heading: "Community" - title: "Contribute to the community" path: /community/contribute/community + - title: "Contribute to SIGs" + path: /community/contribute/sigs - title: "RFC process" path: /community/contribute/rfc_process diff --git a/site/en/community/contribute/code.md b/site/en/community/contribute/code.md index 35f2417046a..2f71f12d7fe 100644 --- a/site/en/community/contribute/code.md +++ b/site/en/community/contribute/code.md @@ -2,14 +2,24 @@ Whether you are adding a loss function, improving test coverage, or writing an RFC for a major design change, this portion of the contributor guide will help -you get started. Thank you for work and interest in improving TensorFlow. +you get started. Thank you for your work and interest in improving TensorFlow. ## Before you get started -Before you contribute source code to a TensorFlow project, please review the `CONTRIBUTING.md` file in the GitHub repo of the project. (For example, see the -[CONTRIBUTING.md file for the core TensorFlow repo](https://github.com/tensorflow/tensorflow/blob/master/CONTRIBUTING.md).) All code contributors are required to sign a [Contributor License Agreement](https://cla.developers.google.com/clas) (CLA). - -To avoid duplicating work, please review [current](https://github.com/tensorflow/community/tree/master/rfcs) or [proposed](https://github.com/tensorflow/community/labels/RFC%3A%20Proposed) RFCs and contact the developers on the TensorFlow forums ([developers@tensorflow.org](https://groups.google.com/u/1/a/tensorflow.org/g/developers)) before you start work on a non-trivial feature. We are somewhat selective when deciding to add new functionality, and the best way to contribute and help the project is to work on known issues. +Before you contribute source code to a TensorFlow project, please review the +`CONTRIBUTING.md` file in the GitHub repo of the project. For example, see the +[CONTRIBUTING.md](https://github.com/tensorflow/tensorflow/blob/master/CONTRIBUTING.md) +file in the core TensorFlow repo. All code contributors are required to sign a +[Contributor License Agreement](https://cla.developers.google.com/clas) (CLA). + +To avoid duplicating work, please review +[current](https://github.com/tensorflow/community/tree/master/rfcs) or +[proposed](https://github.com/tensorflow/community/labels/RFC%3A%20Proposed) +RFCs and contact the developers on the TensorFlow forums +([developers@tensorflow.org](https://groups.google.com/u/1/a/tensorflow.org/g/developers)) +before you start work on a non-trivial feature. We are somewhat selective when +deciding to add new functionality, and the best way to contribute and help the +project is to work on known issues. ## Issues for new contributors @@ -22,14 +32,20 @@ workflow, and for the core devs to become acquainted with the contributor. - [good first issue](https://github.com/tensorflow/tensorflow/labels/good%20first%20issue) - [contributions welcome](https://github.com/tensorflow/tensorflow/labels/stat%3Acontributions%20welcome) -If you are interested in recruiting a team to help tackle a large-scale problem or a new feature, please email the [developers@ group](https://groups.google.com/a/tensorflow.org/forum/#!forum/developers) and review our current list of RFCs. - +If you are interested in recruiting a team to help tackle a large-scale problem +or a new feature, please email the +[developers@ group](https://groups.google.com/a/tensorflow.org/g/developers) +and review our current list of RFCs. ## Code review -New features, bug fixes, and any other changes to the code base are subject to code review. +New features, bug fixes, and any other changes to the code base are subject to +code review. -Reviewing code contributed to the project as pull requests is a crucial component of TensorFlow development. We encourage anyone to start reviewing code submitted by other developers, especially if the feature is something that you are likely to use. +Reviewing code contributed to the project as pull requests is a crucial +component of TensorFlow development. We encourage anyone to start reviewing code +submitted by other developers, especially if the feature is something that you +are likely to use. Here are some questions to keep in mind during the code review process: @@ -44,36 +60,47 @@ Here are some questions to keep in mind during the code review process: ## Test and improve test coverage -High-quality unit testing is a corner-stone of the TensorFlow development process. For this purpose, we use Docker images. The test functions are appropriately named, and are responsible for checking the validity of algorithms as well as different options of the code. +High-quality unit testing is a corner-stone of the TensorFlow development +process. For this purpose, we use Docker images. The test functions are +appropriately named, and are responsible for checking the validity of algorithms +as well as different options of the code. -All new features and bug fixes *must* include adequate test coverage. We also welcome contributions of new test cases or improvements to existing tests. If you discover that our existing tests are not complete — even if that is not currently causing a bug — please file an issue and, if possible, a pull request. +All new features and bug fixes *must* include adequate test coverage. We also +welcome contributions of new test cases or improvements to existing tests. If +you discover that our existing tests are not complete — even if that is not +currently causing a bug — please file an issue and, if possible, a pull request. -For the specific details of testing procedures in each TensorFlow project, see the `README.md` and `CONTRIBUTING.md` files in the project repo on GitHub. +For the specific details of testing procedures in each TensorFlow project, see +the `README.md` and `CONTRIBUTING.md` files in the project repo on GitHub. Of particular concerns in *adequate testing*: -* Is *every public function and class* tested? -* Are a *reasonable set of parameters*, their values, value types, and combinations tested? -* Do the tests validate that the *code is correct*, and that it is *doing what the documentation says* the code is intended to do? +* Is *every public function and class* tested? +* Are a *reasonable set of parameters*, their values, value types, and + combinations tested? +* Do the tests validate that the *code is correct*, and that it is *doing what + the documentation says* the code is intended to do? * If the change is a bug fix, is a *non-regression test* included? * Do the tests *pass the continuous integration* build? -* Do the tests *cover every line of code?* If not, are the exceptions reasonable and explicit? - -If you find any problems, please consider helping the contributor understand those problems and resolve them. +* Do the tests *cover every line of code?* If not, are the exceptions + reasonable and explicit? +If you find any problems, please consider helping the contributor understand +those problems and resolve them. ## Improve error messages or logs -We welcome contributions that improve error messages and logging. - +We welcome contributions that improve error messages and logging. ## Contribution workflow -Code contributions—bug fixes, new development, test improvement—all follow a GitHub-centered workflow. To participate in TensorFlow development, set up a GitHub account. Then: +Code contributions—bug fixes, new development, test improvement—all follow a +GitHub-centered workflow. To participate in TensorFlow development, set up a +GitHub account. Then: -1. Fork the repo you plan to work on. - Go to the project repo page and use the *Fork* button. This will create a copy of the - repo, under your username. (For more details on how to fork a repository see +1. Fork the repo you plan to work on. Go to the project repo page and use the + *Fork* button. This will create a copy of the repo, under your username. + (For more details on how to fork a repository see [this guide](https://help.github.com/articles/fork-a-repo/).) 2. Clone down the repo to your local system. @@ -96,36 +123,46 @@ Code contributions—bug fixes, new development, test improvement—all follow a `$ git push origin branch-name` -7. Open a *Pull Request* (PR). Go to the original project repo on GitHub. There will be a message about your recently pushed branch, asking if you would like to open a pull request. Follow the prompts, *compare across repositories*, and submit the PR. This will send an email to the committers. You may want to consider sending an email to the mailing list for more visibility. (For more details, see the [GitHub guide on PRs](https://help.github.com/articles/creating-a-pull-request-from-a-fork). +7. Open a *Pull Request* (PR). Go to the original project repo on GitHub. There + will be a message about your recently pushed branch, asking if you would + like to open a pull request. Follow the prompts, *compare across + repositories*, and submit the PR. This will send an email to the committers. + You may want to consider sending an email to the mailing list for more + visibility. (For more details, see the + [GitHub guide on PRs](https://help.github.com/articles/creating-a-pull-request-from-a-fork). -8. Maintainers and other contributors will *review your PR*. Please participate in the conversation, and try to *make any requested changes*. Once the PR is approved, the code will be merged. +8. Maintainers and other contributors will *review your PR*. Please participate + in the conversation, and try to *make any requested changes*. Once the PR is + approved, the code will be merged. -*Before working on your next contribution*, make sure your local repository is up to date. +*Before working on your next contribution*, make sure your local repository is +up to date. -1. Set the upstream remote. (You only have to do this once per project, not every time.) +1. Set the upstream remote. (You only have to do this once per project, not + every time.) `$ git remote add upstream git@github.com:tensorflow/project-repo-name` -2. Switch to the local master branch. +2. Switch to the local master branch. `$ git checkout master` -3. Pull down the changes from upstream. +3. Pull down the changes from upstream. `$ git pull upstream master` -4. Push the changes to your GitHub account. (Optional, but a good practice.) +4. Push the changes to your GitHub account. (Optional, but a good practice.) `$ git push origin master` -5. Create a new branch if you are starting new work. +5. Create a new branch if you are starting new work. `$ git checkout -b branch-name` Additional `git` and GitHub resources: * [Git documentation](https://git-scm.com/documentation) -* [Git development workflow](https://docs.scipy.org/doc/numpy/dev/gitwash/development_workflow.html) +* [Git development workflow](https://docs.scipy.org/doc/numpy/dev/development_workflow.html) * [Resolving merge conflicts](https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/). diff --git a/site/en/community/contribute/community.md b/site/en/community/contribute/community.md index 26cb66e6a40..bb2b2035d1b 100644 --- a/site/en/community/contribute/community.md +++ b/site/en/community/contribute/community.md @@ -2,14 +2,28 @@ An open source project isn't just about the code, it's also about the community of users, developers, writers, researchers, and other contributors. You can help grow and support this community. -Please read the TensorFlow [Code and Collaboration governance](https://github.com/tensorflow/community/blob/master/governance/code-and-collaboration.md) +Please read the TensorFlow [Code and Collaboration governance](https://github.com/tensorflow/community/blob/master/governance/code-and-collaboration.md). ## Community support -Many people [ask questions about TensorFlow on Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow). Answering those questions and pointing people to the relevant documentation is a great service to the community. +Many people [ask questions about TensorFlow on the TensorFlow Forum](https://discuss.tensorflow.org/). Answering those questions and pointing people to the relevant documentation is a great service to the community. Some users also ask support questions as GitHub issues. We try to discourage this, as GitHub issues are not the best place to ask for technical support. However, if you notice these issues, you are encouraged to answer them and point people to the relevant documentation. +### TensorFlow Forum + +The [TensorFlow Forum](https://discuss.tensorflow.org/) is a central platform for community discussion and support. It brings our community together to share ideas, best practices and use cases related to TensorFlow. We foster an open and welcoming environment according to the [TensorFlow Code of Conduct](https://discuss.tensorflow.org/faq). + +The TensorFlow Forum is organized by categories, subcategories and tags. We encourage you to create an account and follow categories and tags of interest. When you create a new post, select the most appropriate [category or subcategory](https://discuss.tensorflow.org/categories) and [tags](https://discuss.tensorflow.org/tags) to help other users find your topic. + +For more information on Discourse features, read the [Discourse New User Guide](https://meta.discourse.org/t/discourse-new-user-guide/96331). + +### Become a Forum expert + +Discourse uses [trust levels](https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/) to reward increasing levels of participation in the forum. The Forum facilitates learning by doing, letting you to collect [badges](https://discuss.tensorflow.org/badges) that are displayed on your profile. This is a great way to be recognized for helping fellow community members. The more you invest in helping community members, the more badges and forum tools you will unlock. + +Certain groups, such as TensorFlow Team members and Machine Learning GDEs, display a special icon for easier identification. + ## Communication The TensorFlow community has a number of formal and informal ways of keeping in touch. @@ -18,95 +32,33 @@ The TensorFlow community has a number of formal and informal ways of keeping in The primary communication about work on TensorFlow happens in the [TensorFlow repositories on GitHub](https://github.com/tensorflow). This is the place to discuss bugs, new features, and in-progress work. - - ### Mailing lists -Mailing lists are reserved for announcements and contributor conversation. They are not intended to provide technical support. - -#### General TensorFlow lists +Most communication happens on the TensorFlow Forum. The following mailing lists are still used for announcements and contributor conversations. Note that they are not intended to provide technical support. * [announce@tensorflow.org](mailto:announce@tensorflow.org) — All major releases and important announcements are sent to this mailing group. We recommend that you join this list if you depend on TensorFlow in any way. -* [discuss@tensorflow.org](mailto:discuss@tensorflow.org) — General discussion about TensorFlow development and direction. * [developers@tensorflow.org](mailto:developers@tensorflow.org) — Discussion for developers who are contributing to TensorFlow. +For more information on project-specific communication, visit the [Contribute to SIGs](https://tensorflow.org/community/contribute/sigs) page. + +### Blog and social media + +The [TensorFlow Blog](http://blog.tensorflow.org/) is full of great content both from our team at Google and the broader community. We'd love to hear what you have to say, so if you would like to submit an article for review, please contact us at tensorflow-blog@google.com. Note that we receive many great submissions, and setting expectations, we can only publish a few. + +On [Twitter](https://twitter.com/tensorflow) we share the latest and greatest from our community, and our [YouTube channel](https://www.youtube.com/tensorflow) has free educational content to help you create, understand and deploy models for a variety of applications. + +## TensorFlow Community Spotlight + +The TensorFlow Community Spotlight Program provides an opportunity to showcase your passion projects using TensorFlow. [Submit your project](https://services.google.com/fb/forms/tensorflowprojectrecognitionform/) for a chance to be featured and recognized on TensorFlow’s Twitter account. + +Follow the [#TFCommunitySpotlight](https://twitter.com/hashtag/TFCommunitySpotlight?src=hashtag_click) hashtag and find out more about past winners [here](https://blog.tensorflow.org/2020/11/tensorflow-community-spotlight-program-update.html). + +## User groups + +[TensorFlow User Groups](https://www.tensorflow.org/community/groups) (or TFUGs, for short) are local communities of developers and researchers around the world. If you don’t have a TFUG in your country or city, we encourage you to start one by reaching out to [tfug-help@tensorflow.org](mailto:tfug-help@tensorflow.org). + +## Events + +The TensorFlow team hosts and supports events all around the world! If your TFUG is planning an upcoming event or meetup, please let our Community know by posting about it on the TensorFlow Forum under the [Events category](https://discuss.tensorflow.org/c/events/27). -#### Project-specific lists - -* [docs@tensorflow.org](mailto:docs@tensorflow.org) — If you are interested in contributing to the TensorFlow documentation, join this mailing list. -* [hub@tensorflow.org](mailto:hub@tensorflow.org) — Discussion and collaboration around TensorFlow Hub. -* [magenta-discuss@tensorflow.org](mailto:magenta-discuss@tensorflow.org) — General discussion about Magenta development and direction. -* [swift@tensorflow.org](mailto:swift@tensorflow.org) — Community and collaboration around Swift for TensorFlow. -* [tensor2tensor@tensorflow.org](mailto:tensor2tensor@tensorflow.org) — Discussion and peer support for Tensor2Tensor. -* [tfjs-announce@tensorflow.org](mailto:tfjs-announce@tensorflow.org) — Announcements of new TensorFlow.js releases. -* [tfjs@tensorflow.org](mailto:tfjs@tensorflow.org) — Discussion and peer support for TensorFlow.js. -* [tflite@tensorflow.org](mailto:tflite@tensorflow.org) — Discussion and peer support for TensorFlow Lite. -* [tfprobability@tensorflow.org](mailto:tfprobability@tensorflow.org) — Discussion and peer support for TensorFlow Probability. -* [tpu-users@tensorflow.org](mailto:tpu-users@tensorflow.org) — Community discussion and support for TPU users. - - -### Blog - -We post regularly to the [TensorFlow Blog](http://blog.tensorflow.org/), with content sourced from both TensorFlow developers and the broader community. If you would like to submit an article for review, please contact the TensorFlow Developer Relations team. - -### Social media - -For news and updates from around the universe of TensorFlow projects, follow [@tensorflow](https://twitter.com/tensorflow) on Twitter. To watch TensorFlow-related content, check out our [YouTube](http://youtube.com/tensorflow/) channel. - -### User groups - -TensorFlow has many communities all over the world! For a complete listing, please refer to the [Community](https://www.tensorflow.org/community/groups) section on the TensorFlow website. - -### Special Interest Groups (SIGs) - -To enable focused collaboration on particular areas of TensorFlow, we host Special Interest Groups (SIGs). SIGs do their work in public. If you want to join and contribute, review the work of the group, and get in touch with the relevant SIG leader. Membership policies vary on a per-SIG basis. - - -#### Current SIGs - -As of January 2019, the current TF-SIGs are: - -
SIG Addons - | -Maintains a repository of contributions that conform to well-established API patterns, but implement new functionality not available in core TensorFlow. - | -
SIG Build - | -Focuses on issues surrounding building, packaging, and distribution of TensorFlow. - | -
SIG IO - | -Works on support for file systems and formats other than those in core TensorFlow (such as Apache Ignite FS, or Apache Hadoop SequenceFile), as subclasses of tf.data.Dataset and TensorFlow filesystems. - | -
SIG Networking - | -Maintains network fabrics and protocols not available in core TensorFlow. - | -
SIG TensorBoard - | -Furthers the development and direction of TensorBoard and its plug-ins. - | -
SIG Rust - | -Collaborates on the development of TensorFlow's Rust bindings. - | -
-To update:git remote add upstream git@github.com:tensorflow/docs.git
+git remote add upstream git@github.com:tensorflow/docs.git
# View remote reposgit remote -v
origin git@github.com:username/docs.git (fetch) origin git@github.com:username/docs.git (push) -upstream git@github.com:tensorflow/docs.git (fetch) -upstream git@github.com:tensorflow/docs.git (push) +upstream git@github.com:tensorflow/docs.git (fetch) +upstream git@github.com:tensorflow/docs.git (push)
diff --git a/site/en/community/contribute/docs_ref.md b/site/en/community/contribute/docs_ref.md index bf4bf8ef2f3..41fce4dde40 100644 --- a/site/en/community/contribute/docs_ref.md +++ b/site/en/community/contribute/docs_ref.md @@ -8,7 +8,7 @@ TensorFlow uses [DocTest](https://docs.python.org/3/library/doctest.html) to test code snippets in Python docstrings. The snippet must be executable Python code. To enable testing, prepend the line with `>>>` (three left-angle brackets). For example, here's a excerpt from the `tf.concat` function in the -[array_ops.py](https://www.tensorflow.org/code/tensorflow/python/ops/array_ops.py) +[array_ops.py](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/array_ops.py) source file: ``` @@ -45,6 +45,11 @@ def concat(values, axis, name="concat"): Note: TensorFlow DocTest uses TensorFlow 2 and Python 3. +To assess reference documentation quality, see the example section of the +[TensorFlow 2 API Docs advice](https://docs.google.com/document/d/1e20k9CuaZ_-hp25-sSd8E8qldxKPKQR-SkwojYr_r-U/preview). +(Be aware that the Task Tracker on this sheet is no longer in use.) + + ### Make the code testable with DocTest Currently, many docstrings use backticks (```) to identify code. To make the @@ -95,7 +100,7 @@ TensorFlow uses a few customizations to the builtin doctest logic: ``` def NewLayer(): - “””This layer does cool stuff. + """This layer does cool stuff. Example usage: @@ -103,7 +108,7 @@ TensorFlow uses a few customizations to the builtin doctest logic: >>> new_layer = NewLayer(x) >>> new_layergit checkout master
-git pull upstream master
+git pull upstream master
git push
# Push changes to your GitHub account (defaults to origin)
diff --git a/site/en/community/contribute/docs_style.md b/site/en/community/contribute/docs_style.md index 9c730c7f100..10f18e52699 100644 --- a/site/en/community/contribute/docs_style.md +++ b/site/en/community/contribute/docs_style.md @@ -48,50 +48,94 @@ language after the first backtick group, for example: ```-### Links in Markdown +### Links in Markdown and notebooks -#### Links between files in this repository +#### Links between files in a repository -Use relative links between files in a repository. This works on -[tensorflow.org](https://www.tensorflow.org) and -[GitHub](https://github.com/tensorflow/docs/tree/master/site/en):
\[Custom layers\]\(../tutorials/eager/custom_layers.ipynb\)
produces
-[Custom layers](https://www.tensorflow.org/tutorials/eager/custom_layers) on the
-site.
+Use relative links between files in a single GitHub repository. Include the file
+extension.
-#### Links to API documentation
-
-API links are converted when the site is published. To link to a symbol's API
-reference page, enclose the full symbol path in backticks:
+For example, **this file you're reading** is from the
+[https://github.com/tensorflow/docs](https://github.com/tensorflow/docs)
+repository. Therefore, it can use relative paths to link to other files in the same
+repository like this:
-* `tf.data.Dataset`
produces
- [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset)
+* \[Basics\]\(../../guide/basics.ipynb\)
produces
+[Basics](../../guide/basics.ipynb).
-For the C++ API, use the namespace path:
+This is the preferred approach because this way the links on
+[tensorflow.org](https://www.tensorflow.org),
+[GitHub](https://github.com/tensorflow/docs) and
+[Colab](https://github.com/tensorflow/docs/tree/master/site/en/guide/bazics.ipynb)
+all work. Also, the reader stays in the same site when they click a link.
-* `tensorflow::Tensor` produces
- [tensorflow::Tensor](https://www.tensorflow.org/api_docs/cc/class/tensorflow/tensor)
+Note: You should include the file extension—such as `.ipynb` or `.md`—for
+relative links. It will rendered on `tensorflow.org` without an extension.
#### External links
-For external links, including files on https://www.tensorflow.org
-that are not in the `tensorflow/docs` repository, use standard Markdown links
-with the full URI.
+For links to files that are not in the current repository, use standard Markdown
+links with the full URI. Prefer to link to the
+[tensorflow.org](https://www.tensorflow.org) URI if it's available.
To link to source code, use a link starting with
https://www.github.com/tensorflow/tensorflow/blob/master/, followed
by the file name starting at the GitHub root.
-This URI naming scheme ensures that https://www.tensorflow.org can
-forward the link to the branch of the code corresponding to the version of the
-documentation you're viewing.
+When linking off of [tensorflow.org](https://www.tensorflow.org), include a
+`` on the Markdown link so that the "external link" symbol is shown.
+
+* `[GitHub](https://github.com/tensorflow/docs)` produces
+ [GitHub](https://github.com/tensorflow/docs)
+
+Do not include URI query parameters in the link:
+
+* Use: `https://www.tensorflow.org/guide/data`
+* Not: `https://www.tensorflow.org/guide/data?hl=en`
+
+
+#### Images
+
+The advice in the previous section is for links to pages. Images are handled
+differently.
+
+Generally, you should not check in images, and instead add the
+[TensorFlow-Docs team](https://github.com/tensorflow/docs) to your PR, and ask
+them to host the images on [tensorflow.org](https://www.tensorflow.org).
+This helps keep the size of your repository down.
+
+If you do submit images to your repository, note that some systems do not handle
+relative paths to images. Prefer to use a full URL pointing to the image's
+eventual location on [tensorflow.org](https://www.tensorflow.org).
+
+#### Links to API documentation
+
+API links are converted when the site is published. To link to a symbol's API
+reference page, enclose the symbol path in backticks:
+
+* `tf.data.Dataset`
produces
+ [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset)
+
+Full paths are slightly preferred except for long paths. Paths
+can be abbreviated by dropping the leading path components. Partial paths will
+be converted to links if:
+
+* There is at least one `.` in the path, and
+* The partial path is unique within the project.
+
+API paths are linked **for every project** with a Python API published on
+[tensorflow.org](https://www.tensorflow.org). You can easily link to multiple
+subprojects from a single file by wrapping the API names with backticks.
+For example:
-Do not include URI query parameters in the link.
+* `tf.metrics`
, `tf_agents.metrics`
,
+ `text.metrics`
produces: `tf.metrics`,
+ `tf_agents.metrics`, `text.metrics`.
-File paths use underscores for spaces, for example, `custom_layers.ipynb`.
+For symbols with multiple path aliases there is a slight preference for the
+path that matches the API-page on [tensorflow.org](https://www.tensorflow.org).
+All aliases will redirect to the correct page.
-Include the file extension in links to use on the site *and* GitHub, for example,\[Custom layers\]\(../tutorials/eager/custom_layers.ipynb\)
.
### Math in Markdown
diff --git a/site/en/community/contribute/sigs.md b/site/en/community/contribute/sigs.md
new file mode 100644
index 00000000000..b736ec5919a
--- /dev/null
+++ b/site/en/community/contribute/sigs.md
@@ -0,0 +1,97 @@
+# Contribute to TensorFlow Special Interest Groups (SIGs)
+
+The TensorFlow Special Interest Groups (TF SIGs) organize community contributions to key parts of the TensorFlow ecosystem. SIG leads and members work together to build and support important TensorFlow use cases.
+
+SIGs are led by members of the open source community, including industry collaborators and [Machine Learning Google Developer Experts](https://developers.google.com/community/experts) (ML GDEs). TensorFlow's success is due in large part to their hard work and contributions.
+
+We encourage you to join a SIG working on the area of TensorFlow's ecosystem you care most about. Not all SIGs will have the same level of energy, breadth of scope, or governance models — browse our [SIG charters](https://github.com/tensorflow/community/tree/master/sigs) to learn more. Stay connected with SIG leads and members on the [TensorFlow Forum](https://discuss.tensorflow.org/c/special-interest-groups/8), where you can subscribe to preferred [tags](https://discuss.tensorflow.org/tags) and learn more about the regular SIG meetings.
+
+## SIG Addons
+
+SIG Addons builds and maintains a repository of community 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, optimizers, and more. However, in a fast-moving field like ML, there are many 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). SIG Addons enables users to introduce new extensions to the TensorFlow ecosystem in a sustainable manner.
+
+SIG Addons on GitHub Contributing Discuss on the Forum
+
+## SIG Build
+
+SIG Build improves and extends the TensorFlow build process. SIG Build maintains a repository showcasing resources, guides, tools, and builds contributed by the community, for the community.
+
+SIG Build on GitHub Contributing Discuss on the Forum
+
+## SIG IO
+
+SIG IO maintains TensorFlow I/O, a collection of file systems and file formats that are not available in TensorFlow's built-in support.
+
+SIG IO on GitHub Contributing Discuss on the Forum
+
+## SIG JVM
+
+SIG JVM maintains the TF Java bindings to let users use JVM for building, training and running machine learning models.
+
+Java and other JVM languages, such as Scala or Kotlin, are frequently used in small-to-large enterprises all over the world, which makes TensorFlow a strategic choice for adopting machine learning at a large scale.
+
+SIG JVM on GitHub Contributing Discuss on the Forum
+
+## SIG Models
+
+SIG Models focuses on enabling contributions to the state-of-the-art model implementation in TensorFlow 2, and sharing best practices of using TensorFlow 2 for state-of-the-art research. Subgroups orient around different machine learning applications (Vision, NLP, etc.).
+
+SIG Models host discussions and collaborations around the [TensorFlow Model Garden](https://github.com/tensorflow/models) and [TensorFlow Hub](https://tfhub.dev). Learn how to contribute on GitHub below, or discuss [Research & Models](https://discuss.tensorflow.org/c/research-models/26) on the Forum.
+
+TensorFlow Model Garden on GitHub Contributing
+
+TensorFlow Hub on GitHub Contributing
+
+## SIG Micro
+
+SIG Micro discusses and shares updates on [TensorFlow Lite for Microcontrollers](https://www.tensorflow.org/lite/microcontrollers), a port of TensorFlow Lite designed to run machine learning models on DSPs, microcontrollers and other devices with limited memory.
+
+TensorFlow Lite Micro on GitHub Contributing Discuss on the Forum
+
+## SIG MLIR
+
+SIG MLIR maintains [MLIR](https://mlir.llvm.org/) dialects and utilities for TensorFlow, XLA and TF Lite, providing high performance compilers and optimization techniques that can be applied to TensorFlow graphs and code generation. Their overarching goal is to create common intermediate representation (IR) that reduces the cost to bring up new hardware, and improve usability for existing TensorFlow users.
+
+SIG MLIR on GitHub Contributing Discuss on the Forum
+
+## SIG Networking
+
+SIG Networking maintains the TensorFlow Networking repository for platform-specific networking extensions to core TensorFlow and related utilities.
+
+SIG Networking on GitHub Discuss on the Forum
+
+## SIG Recommenders
+
+SIG Recommenders maintains a collection of projects related to large-scale recommendation systems built upon TensorFlow contributed and maintained by the community. Those contributions are complementary to [TensorFlow Core](https://www.tensorflow.org/overview) and [TensorFlow Recommenders](https://www.tensorflow.org/recommenders).
+
+SIG Recommenders on GitHub Contributing Discuss on the Forum
+
+## SIG Rust
+
+SIG Rust maintains idiomatic Rust language bindings for TensorFlow.
+
+SIG Rust on GitHub Contributing Discuss on the Forum
+
+## SIG TensorBoard
+
+SIG TensorBoard facilitates discussion around [TensorBoard](https://www.tensorflow.org/tensorboard)—a suite of tools for inspecting, debugging and optimizing TensorFlow programs.
+
+TensorBoard on GitHub Contributing Discuss on the Forum
+
+## SIG TF.js
+
+SIG TF.js facilitates community-contributed components to [TensorFlow.js](https://www.tensorflow.org/js) and offers project support through the SIG.
+
+TensorFlow.js on GitHub Contributing Discuss on the Forum
+
+## SIG TFX-Addons
+
+SIG TFX-Addons accelerates the sharing of customizations and additions to meet the needs of production ML, expand the vision, and help drive new directions for [TensorFlow Extended (TFX)](https://www.tensorflow.org/tfx) and the ML community.
+
+SIG TFX-Addons on GitHub Contributing Discuss on the Forum
+
+## New SIGs
+
+Didn't find what you were looking for? If you believe there is a strong need for a new TensorFlow SIG, please read the [SIG playbook](https://www.tensorflow.org/community/sig_playbook) and follow instructions on how to propose it to our contributor community.
diff --git a/site/en/community/mailing-lists.md b/site/en/community/mailing-lists.md
index a33f758cdbf..35bfb218ba1 100644
--- a/site/en/community/mailing-lists.md
+++ b/site/en/community/mailing-lists.md
@@ -2,11 +2,12 @@
As a community, we do much of our collaboration on public mailing lists. Please
note that if you're looking for help using TensorFlow,
-[Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow) and
+[TensorFlow Forum](https://discuss.tensorflow.org/),
+[Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow), and
[GitHub issues](https://github.com/tensorflow/tensorflow/issues) are the best
-initial places to look.
+initial places to look. To receive a roundup of updates from the TensorFlow team each quarter, subscribe to the [TensorFlow newsletter](https://services.google.com/fb/forms/tensorflow/).
-## General TensorFlow lists
+## General TensorFlow lists and forums
* [announce](https://groups.google.com/a/tensorflow.org/d/forum/announce) -
Low-volume announcements of new releases.
@@ -14,7 +15,7 @@ initial places to look.
General community discussion around TensorFlow.
* [developers](https://groups.google.com/a/tensorflow.org/d/forum/developers) -
Discussion for developers contributing to TensorFlow.
-* [documentation](https://groups.google.com/a/tensorflow.org/d/forum/docs) -
+* [documentation](https://discuss.tensorflow.org/tag/docs) -
Discussion for contributing to TensorFlow documentation. See
[community translations](https://www.tensorflow.org/community/contribute/docs#community_translations)
for language-specific docs lists.
diff --git a/site/en/community/sig_playbook.md b/site/en/community/sig_playbook.md
index 75e277d3d96..6ec7a554a5b 100644
--- a/site/en/community/sig_playbook.md
+++ b/site/en/community/sig_playbook.md
@@ -55,7 +55,7 @@ must demonstrate:
application area)
* Two or more contributors willing to act as group leads, existence of other
contributors, and evidence of demand for the group
-* Resources it will initially require (usually, mailing list and regular VC
+* Resources it will initially require (usually, mailing list and regular video conference
call.)
Approval for the group will be given by a decision of the TF Community Team,
diff --git a/site/en/datasets/README.md b/site/en/datasets/README.md
deleted file mode 100644
index 422d0b5c9a3..00000000000
--- a/site/en/datasets/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-Welcome to the warp zone!
-
-# TensorFlow Datasets
-
-These docs are available here: https://github.com/tensorflow/datasets/tree/master/docs
diff --git a/site/en/federated/README.md b/site/en/federated/README.md
deleted file mode 100644
index 518fde837cb..00000000000
--- a/site/en/federated/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Welcome to the warp zone!
-
-# TensorFlow Federated
-
-These docs are available here:
-https://github.com/tensorflow/federated/tree/main/docs
diff --git a/site/en/graphics/README.md b/site/en/graphics/README.md
deleted file mode 100644
index 9182fae0c12..00000000000
--- a/site/en/graphics/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-Welcome to the warp zone!
-
-# TensorFlow Graphics
-
-These docs are available here: https://github.com/tensorflow/graphics/tree/master/tensorflow_graphics/g3doc
diff --git a/site/en/guide/_index.yaml b/site/en/guide/_index.yaml
index f9d873dbf2a..e39dd37ead5 100644
--- a/site/en/guide/_index.yaml
+++ b/site/en/guide/_index.yaml
@@ -95,10 +95,11 @@ landing_page:
items:
- list:
- description: >
- \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
tf.Operation
+as its parameter type.
+
### Shape functions in C++
The TensorFlow API has a feature called "shape inference" that provides
@@ -1404,7 +1412,7 @@ be set to the first input's shape. If the output is selected by its index as in
There are a number of common shape functions
that apply to many ops, such as `shape_inference::UnchangedShape` which can be
-found in [common_shape_fns.h](https://www.tensorflow.org/code/tensorflow/core/framework/common_shape_fns.h) and used as follows:
+found in [common_shape_fns.h](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/common_shape_fns.h) and used as follows:
```c++
REGISTER_OP("ZeroOut")
@@ -1451,7 +1459,7 @@ provides access to the attributes of the op).
Since shape inference is an optional feature, and the shapes of tensors may vary
dynamically, shape functions must be robust to incomplete shape information for
-any of the inputs. The `Merge` method in [`InferenceContext`](https://www.tensorflow.org/code/tensorflow/core/framework/shape_inference.h)
+any of the inputs. The `Merge` method in [`InferenceContext`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/shape_inference.h)
allows the caller to assert that two shapes are the same, even if either
or both of them do not have complete information. Shape functions are defined
for all of the core TensorFlow ops and provide many different usage examples.
@@ -1476,7 +1484,7 @@ If you have a complicated shape function, you should consider adding a test for
validating that various input shape combinations produce the expected output
shape combinations. You can see examples of how to write these tests in some
our
-[core ops tests](https://www.tensorflow.org/code/tensorflow/core/ops/array_ops_test.cc).
+[core ops tests](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/ops/array_ops_test.cc).
(The syntax of `INFER_OK` and `INFER_ERROR` are a little cryptic, but try to be
compact in representing input and output shape specifications in tests. For
now, see the surrounding comments in those tests to get a sense of the shape
@@ -1489,20 +1497,20 @@ To build a `pip` package for your op, see the
guide shows how to build custom ops from the TensorFlow pip package instead
of building TensorFlow from source.
-[core-array_ops]:https://www.tensorflow.org/code/tensorflow/core/ops/array_ops.cc
-[python-user_ops]:https://www.tensorflow.org/code/tensorflow/python/user_ops/user_ops.py
-[tf-kernels]:https://www.tensorflow.org/code/tensorflow/core/kernels/
-[user_ops]:https://www.tensorflow.org/code/tensorflow/core/user_ops/
-[pad_op]:https://www.tensorflow.org/code/tensorflow/core/kernels/pad_op.cc
-[standard_ops-py]:https://www.tensorflow.org/code/tensorflow/python/ops/standard_ops.py
-[standard_ops-cc]:https://www.tensorflow.org/code/tensorflow/cc/ops/standard_ops.h
-[python-BUILD]:https://www.tensorflow.org/code/tensorflow/python/BUILD
-[validation-macros]:https://www.tensorflow.org/code/tensorflow/core/lib/core/errors.h
-[op_def_builder]:https://www.tensorflow.org/code/tensorflow/core/framework/op_def_builder.h
-[register_types]:https://www.tensorflow.org/code/tensorflow/core/framework/register_types.h
-[FinalizeAttr]:https://www.tensorflow.org/code/tensorflow/core/framework/op_def_builder.cc
-[DataTypeString]:https://www.tensorflow.org/code/tensorflow/core/framework/types.cc
-[python-BUILD]:https://www.tensorflow.org/code/tensorflow/python/BUILD
-[types-proto]:https://www.tensorflow.org/code/tensorflow/core/framework/types.proto
-[TensorShapeProto]:https://www.tensorflow.org/code/tensorflow/core/framework/tensor_shape.proto
-[TensorProto]:https://www.tensorflow.org/code/tensorflow/core/framework/tensor.proto
+[core-array_ops]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/ops/array_ops.cc
+[python-user_ops]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/user_ops/user_ops.py
+[tf-kernels]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/
+[user_ops]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/user_ops/
+[pad_op]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/pad_op.cc
+[standard_ops-py]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/standard_ops.py
+[standard_ops-cc]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/cc/ops/standard_ops.h
+[python-BUILD]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/BUILD
+[validation-macros]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/platform/errors.h
+[op_def_builder]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/op_def_builder.h
+[register_types]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/register_types.h
+[FinalizeAttr]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/op_def_builder.cc
+[DataTypeString]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/types.cc
+[python-BUILD]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/BUILD
+[types-proto]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/types.proto
+[TensorShapeProto]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/tensor_shape.proto
+[TensorProto]:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/tensor.proto
diff --git a/site/en/guide/data.ipynb b/site/en/guide/data.ipynb
index 42146ac9a01..739ef131005 100644
--- a/site/en/guide/data.ipynb
+++ b/site/en/guide/data.ipynb
@@ -15,7 +15,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
- "cellView": "form",
"id": "llMNufAK7nfK"
},
"outputs": [],
@@ -139,8 +138,8 @@
"\n",
"Once you have a `Dataset` object, you can *transform* it into a new `Dataset` by\n",
"chaining method calls on the `tf.data.Dataset` object. For example, you can\n",
- "apply per-element transformations such as `Dataset.map()`, and multi-element\n",
- "transformations such as `Dataset.batch()`. See the documentation for\n",
+ "apply per-element transformations such as `Dataset.map`, and multi-element\n",
+ "transformations such as `Dataset.batch`. Refer to the documentation for\n",
"`tf.data.Dataset` for a complete list of transformations.\n",
"\n",
"The `Dataset` object is a Python iterable. This makes it possible to consume its\n",
@@ -238,9 +237,9 @@
"structure of elements include `tuple`, `dict`, `NamedTuple`, and\n",
"`OrderedDict`. In particular, `list` is not a valid construct for\n",
"expressing the structure of dataset elements. This is because\n",
- "early tf.data users felt strongly about `list` inputs (e.g. passed\n",
+ "early `tf.data` users felt strongly about `list` inputs (for example, when passed\n",
"to `tf.data.Dataset.from_tensors`) being automatically packed as\n",
- "tensors and `list` outputs (e.g. return values of user-defined\n",
+ "tensors and `list` outputs (for example, return values of user-defined\n",
"functions) being coerced into a `tuple`. As a consequence, if you\n",
"would like a `list` input to be treated as a structure, you need\n",
"to convert it into `tuple` and if you would like a `list` output\n",
@@ -328,7 +327,7 @@
},
"source": [
"The `Dataset` transformations support datasets of any structure. When using the\n",
- "`Dataset.map()`, and `Dataset.filter()` transformations,\n",
+ "`Dataset.map`, and `Dataset.filter` transformations,\n",
"which apply a function to each element, the element structure determines the\n",
"arguments of the function:"
]
@@ -416,11 +415,11 @@
"source": [
"### Consuming NumPy arrays\n",
"\n",
- "See [Loading NumPy arrays](../tutorials/load_data/numpy.ipynb) for more examples.\n",
+ "Refer to the [Loading NumPy arrays](../tutorials/load_data/numpy.ipynb) tutorial for more examples.\n",
"\n",
"If all of your input data fits in memory, the simplest way to create a `Dataset`\n",
"from them is to convert them to `tf.Tensor` objects and use\n",
- "`Dataset.from_tensor_slices()`."
+ "`Dataset.from_tensor_slices`."
]
},
{
@@ -472,7 +471,7 @@
"\n",
"Another common data source that can easily be ingested as a `tf.data.Dataset` is the python generator.\n",
"\n",
- "Caution: While this is a convienient approach it has limited portability and scalibility. It must run in the same python process that created the generator, and is still subject to the Python [GIL](https://en.wikipedia.org/wiki/Global_interpreter_lock)."
+ "Caution: While this is a convenient approach it has limited portability and scalability. It must run in the same python process that created the generator, and is still subject to the Python [GIL](https://en.wikipedia.org/wiki/Global_interpreter_lock)."
]
},
{
@@ -544,11 +543,11 @@
"id": "wxy9hDMTq1zD"
},
"source": [
- "The `output_shapes` argument is not *required* but is highly recomended as many tensorflow operations do not support tensors with unknown rank. If the length of a particular axis is unknown or variable, set it as `None` in the `output_shapes`.\n",
+ "The `output_shapes` argument is not *required* but is highly recommended as many TensorFlow operations do not support tensors with an unknown rank. If the length of a particular axis is unknown or variable, set it as `None` in the `output_shapes`.\n",
"\n",
"It's also important to note that the `output_shapes` and `output_types` follow the same nesting rules as other dataset methods.\n",
"\n",
- "Here is an example generator that demonstrates both aspects, it returns tuples of arrays, where the second array is a vector with unknown length."
+ "Here is an example generator that demonstrates both aspects: it returns tuples of arrays, where the second array is a vector with unknown length."
]
},
{
@@ -589,7 +588,7 @@
"source": [
"The first output is an `int32` the second is a `float32`.\n",
"\n",
- "The first item is a scalar, shape `()`, and the second is a vector of unknown length, shape `(None,)` "
+ "The first item is a scalar, shape `()`, and the second is a vector of unknown length, shape `(None,)`"
]
},
{
@@ -601,8 +600,8 @@
"outputs": [],
"source": [
"ds_series = tf.data.Dataset.from_generator(\n",
- " gen_series, \n",
- " output_types=(tf.int32, tf.float32), \n",
+ " gen_series,\n",
+ " output_types=(tf.int32, tf.float32),\n",
" output_shapes=((), (None,)))\n",
"\n",
"ds_series"
@@ -710,8 +709,8 @@
"outputs": [],
"source": [
"ds = tf.data.Dataset.from_generator(\n",
- " lambda: img_gen.flow_from_directory(flowers), \n",
- " output_types=(tf.float32, tf.float32), \n",
+ " lambda: img_gen.flow_from_directory(flowers),\n",
+ " output_types=(tf.float32, tf.float32),\n",
" output_shapes=([32,256,256,3], [32,5])\n",
")\n",
"\n",
@@ -726,7 +725,7 @@
},
"outputs": [],
"source": [
- "for images, label in ds.take(1):\n",
+ "for images, labels in ds.take(1):\n",
" print('images.shape: ', images.shape)\n",
" print('labels.shape: ', labels.shape)\n"
]
@@ -739,7 +738,7 @@
"source": [
"### Consuming TFRecord data\n",
"\n",
- "See [Loading TFRecords](../tutorials/load_data/tfrecord.ipynb) for an end-to-end example.\n",
+ "Refer to the [Loading TFRecords](../tutorials/load_data/tfrecord.ipynb) tutorial for an end-to-end example.\n",
"\n",
"The `tf.data` API supports a variety of file formats so that you can process\n",
"large datasets that do not fit in memory. For example, the TFRecord file format\n",
@@ -825,7 +824,7 @@
"source": [
"### Consuming text data\n",
"\n",
- "See [Loading Text](../tutorials/load_data/text.ipynb) for an end to end example.\n",
+ "Refer to the [Load text](../tutorials/load_data/text.ipynb) tutorial for an end-to-end example.\n",
"\n",
"Many datasets are distributed as one or more text files. The\n",
"`tf.data.TextLineDataset` provides an easy way to extract lines from one or more\n",
@@ -916,7 +915,7 @@
"source": [
"By default, a `TextLineDataset` yields *every* line of each file, which may\n",
"not be desirable, for example, if the file starts with a header line, or contains comments. These lines can be removed using the `Dataset.skip()` or\n",
- "`Dataset.filter()` transformations. Here, you skip the first line, then filter to\n",
+ "`Dataset.filter` transformations. Here, you skip the first line, then filter to\n",
"find only survivors."
]
},
@@ -985,7 +984,7 @@
"id": "ChDHNi3qbDch"
},
"source": [
- "See [Loading CSV Files](../tutorials/load_data/csv.ipynb), and [Loading Pandas DataFrames](../tutorials/load_data/pandas_dataframe.ipynb) for more examples. \n",
+ "Refer to the [Loading CSV Files](../tutorials/load_data/csv.ipynb) and [Loading Pandas DataFrames](../tutorials/load_data/pandas_dataframe.ipynb) tutorials for more examples.\n",
"\n",
"The CSV file format is a popular format for storing tabular data in plain text.\n",
"\n",
@@ -1045,11 +1044,11 @@
"id": "47yippqaHFk6"
},
"source": [
- "A more scalable approach is to load from disk as necessary. \n",
+ "A more scalable approach is to load from disk as necessary.\n",
"\n",
"The `tf.data` module provides methods to extract records from one or more CSV files that comply with [RFC 4180](https://tools.ietf.org/html/rfc4180).\n",
"\n",
- "The `experimental.make_csv_dataset` function is the high level interface for reading sets of csv files. It supports column type inference and many other features, like batching and shuffling, to make usage simple."
+ "The `tf.data.experimental.make_csv_dataset` function is the high-level interface for reading sets of CSV files. It supports column type inference and many other features, like batching and shuffling, to make usage simple."
]
},
{
@@ -1122,7 +1121,7 @@
"id": "TSVgJJ1HJD6M"
},
"source": [
- "There is also a lower-level `experimental.CsvDataset` class which provides finer grained control. It does not support column type inference. Instead you must specify the type of each column. "
+ "There is also a lower-level `experimental.CsvDataset` class which provides finer grained control. It does not support column type inference. Instead you must specify the type of each column."
]
},
{
@@ -1133,7 +1132,7 @@
},
"outputs": [],
"source": [
- "titanic_types = [tf.int32, tf.string, tf.float32, tf.int32, tf.int32, tf.float32, tf.string, tf.string, tf.string, tf.string] \n",
+ "titanic_types = [tf.int32, tf.string, tf.float32, tf.int32, tf.int32, tf.float32, tf.string, tf.string, tf.string, tf.string]\n",
"dataset = tf.data.experimental.CsvDataset(titanic_file, titanic_types , header=True)\n",
"\n",
"for line in dataset.take(10):\n",
@@ -1386,7 +1385,7 @@
"The simplest form of batching stacks `n` consecutive elements of a dataset into\n",
"a single element. The `Dataset.batch()` transformation does exactly this, with\n",
"the same constraints as the `tf.stack()` operator, applied to each component\n",
- "of the elements: i.e. for each component *i*, all elements must have a tensor\n",
+ "of the elements: i.e., for each component *i*, all elements must have a tensor\n",
"of the exact same shape."
]
},
@@ -1457,10 +1456,10 @@
"### Batching tensors with padding\n",
"\n",
"The above recipe works for tensors that all have the same size. However, many\n",
- "models (e.g. sequence models) work with input data that can have varying size\n",
- "(e.g. sequences of different lengths). To handle this case, the\n",
+ "models (including sequence models) work with input data that can have varying size\n",
+ "(for example, sequences of different lengths). To handle this case, the\n",
"`Dataset.padded_batch` transformation enables you to batch tensors of\n",
- "different shape by specifying one or more dimensions in which they may be\n",
+ "different shapes by specifying one or more dimensions in which they may be\n",
"padded."
]
},
@@ -1604,7 +1603,7 @@
"id": "DlEM5f9loSHR"
},
"source": [
- "If you would like to perform a custom computation (e.g. to collect statistics) at the end of each epoch then it's simplest to restart the dataset iteration on each epoch:"
+ "If you would like to perform a custom computation (for example, to collect statistics) at the end of each epoch then it's simplest to restart the dataset iteration on each epoch:"
]
},
{
@@ -1693,7 +1692,7 @@
"source": [
"As with `Dataset.batch` the order relative to `Dataset.repeat` matters.\n",
"\n",
- "`Dataset.shuffle` doesn't signal the end of an epoch until the shuffle buffer is empty. So a shuffle placed before a repeat will show every element of one epoch before moving to the next: "
+ "`Dataset.shuffle` doesn't signal the end of an epoch until the shuffle buffer is empty. So a shuffle placed before a repeat will show every element of one epoch before moving to the next:"
]
},
{
@@ -1838,7 +1837,7 @@
" label = parts[-2]\n",
"\n",
" image = tf.io.read_file(filename)\n",
- " image = tf.image.decode_jpeg(image)\n",
+ " image = tf.io.decode_jpeg(image)\n",
" image = tf.image.convert_image_dtype(image, tf.float32)\n",
" image = tf.image.resize(image, [128, 128])\n",
" return image, label"
@@ -1906,7 +1905,7 @@
"\n",
"For performance reasons, use TensorFlow operations for\n",
"preprocessing your data whenever possible. However, it is sometimes useful to\n",
- "call external Python libraries when parsing your input data. You can use the `tf.py_function()` operation in a `Dataset.map()` transformation."
+ "call external Python libraries when parsing your input data. You can use the `tf.py_function` operation in a `Dataset.map` transformation."
]
},
{
@@ -1915,7 +1914,7 @@
"id": "R2u7CeA67DU8"
},
"source": [
- "For example, if you want to apply a random rotation, the `tf.image` module only has `tf.image.rot90`, which is not very useful for image augmentation. \n",
+ "For example, if you want to apply a random rotation, the `tf.image` module only has `tf.image.rot90`, which is not very useful for image augmentation.\n",
"\n",
"Note: `tensorflow_addons` has a TensorFlow compatible `rotate` in `tensorflow_addons.image.rotate`.\n",
"\n",
@@ -1932,6 +1931,7 @@
"source": [
"import scipy.ndimage as ndimage\n",
"\n",
+ "@tf.py_function(Tout=tf.float32)\n",
"def random_rotate_image(image):\n",
" image = ndimage.rotate(image, np.random.uniform(-30, 30), reshape=False)\n",
" return image"
@@ -1969,7 +1969,7 @@
"source": [
"def tf_random_rotate_image(image, label):\n",
" im_shape = image.shape\n",
- " [image,] = tf.py_function(random_rotate_image, [image], [tf.float32])\n",
+ " image = random_rotate_image(image)\n",
" image.set_shape(im_shape)\n",
" return image, label"
]
@@ -2124,7 +2124,7 @@
"id": "t0JMgvXEz9y1"
},
"source": [
- "For an end to end time series example see: [Time series forecasting](../../tutorials/structured_data/time_series.ipynb)."
+ "For an end-to-end time series example see: [Time series forecasting](../../tutorials/structured_data/time_series.ipynb)."
]
},
{
@@ -2155,7 +2155,7 @@
"id": "o6GLGhxgpazJ"
},
"source": [
- "Typically, models based on this sort of data will want a contiguous time slice. \n",
+ "Typically, models based on this sort of data will want a contiguous time slice.\n",
"\n",
"The simplest approach would be to batch the data:"
]
@@ -2283,7 +2283,7 @@
"id": "fF6pEdlduq8E"
},
"source": [
- "While using `Dataset.batch` works, there are situations where you may need finer control. The `Dataset.window` method gives you complete control, but requires some care: it returns a `Dataset` of `Datasets`. See [Dataset structure](#dataset_structure) for details."
+ "While using `Dataset.batch` works, there are situations where you may need finer control. The `Dataset.window` method gives you complete control, but requires some care: it returns a `Dataset` of `Datasets`. Go to the [Dataset structure](#dataset_structure) section for details."
]
},
{
@@ -2328,7 +2328,7 @@
"id": "sgLIwq9Anc34"
},
"source": [
- "In nearly all cases, you will want to `.batch` the dataset first:"
+ "In nearly all cases, you will want to `Dataset.batch` the dataset first:"
]
},
{
@@ -2422,7 +2422,7 @@
"\n",
"When working with a dataset that is very class-imbalanced, you may want to resample the dataset. `tf.data` provides two methods to do this. The credit card fraud dataset is a good example of this sort of problem.\n",
"\n",
- "Note: See [Imbalanced Data](../tutorials/keras/imbalanced_data.ipynb) for a full tutorial.\n"
+ "Note: Go to [Classification on imbalanced data](../tutorials/structured_data/imbalanced_data.ipynb) for a full tutorial.\n"
]
},
{
@@ -2529,7 +2529,7 @@
"id": "ov14SRrQyQE3"
},
"source": [
- "One approach to resampling a dataset is to use `sample_from_datasets`. This is more applicable when you have a separate `data.Dataset` for each class.\n",
+ "One approach to resampling a dataset is to use `sample_from_datasets`. This is more applicable when you have a separate `tf.data.Dataset` for each class.\n",
"\n",
"Here, just use filter to generate them from the credit card fraud data:"
]
@@ -2572,7 +2572,7 @@
"id": "GxLAr-7p0ATX"
},
"source": [
- "To use `tf.data.experimental.sample_from_datasets` pass the datasets, and the weight for each:"
+ "To use `tf.data.Dataset.sample_from_datasets` pass the datasets, and the weight for each:"
]
},
{
@@ -2583,7 +2583,7 @@
},
"outputs": [],
"source": [
- "balanced_ds = tf.data.experimental.sample_from_datasets(\n",
+ "balanced_ds = tf.data.Dataset.sample_from_datasets(\n",
" [negative_ds, positive_ds], [0.5, 0.5]).batch(10)"
]
},
@@ -2593,7 +2593,7 @@
"id": "2K4ObOms082B"
},
"source": [
- "Now the dataset produces examples of each class with 50/50 probability:"
+ "Now the dataset produces examples of each class with a 50/50 probability:"
]
},
{
@@ -2623,15 +2623,15 @@
"id": "kZ9ezkK6irMD"
},
"source": [
- "One problem with the above `experimental.sample_from_datasets` approach is that\n",
- "it needs a separate `tf.data.Dataset` per class. Using `Dataset.filter`\n",
- "works, but results in all the data being loaded twice.\n",
+ "One problem with the above `Dataset.sample_from_datasets` approach is that\n",
+ "it needs a separate `tf.data.Dataset` per class. You could use `Dataset.filter`\n",
+ "to create those two datasets, but that results in all the data being loaded twice.\n",
"\n",
- "The `data.experimental.rejection_resample` function can be applied to a dataset to rebalance it, while only loading it once. Elements will be dropped from the dataset to achieve balance.\n",
+ "The `tf.data.Dataset.rejection_resample` method can be applied to a dataset to rebalance it, while only loading it once. Elements will be dropped or repeated to achieve balance.\n",
"\n",
- "`data.experimental.rejection_resample` takes a `class_func` argument. This `class_func` is applied to each dataset element, and is used to determine which class an example belongs to for the purposes of balancing.\n",
+ "The `rejection_resample` method takes a `class_func` argument. This `class_func` is applied to each dataset element, and is used to determine which class an example belongs to for the purposes of balancing.\n",
"\n",
- "The elements of `creditcard_ds` are already `(features, label)` pairs. So the `class_func` just needs to return those labels:"
+ "The goal here is to balance the label distribution, and the elements of `creditcard_ds` are already `(features, label)` pairs. So the `class_func` just needs to return those labels:"
]
},
{
@@ -2646,34 +2646,15 @@
" return label"
]
},
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "DdKmE8Jumlp0"
- },
- "source": [
- "The resampler also needs a target distribution, and optionally an initial distribution estimate:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "id": "9tv0tWNxmkzM"
- },
- "outputs": [],
- "source": [
- "resampler = tf.data.experimental.rejection_resample(\n",
- " class_func, target_dist=[0.5, 0.5], initial_dist=fractions)"
- ]
- },
{
"cell_type": "markdown",
"metadata": {
"id": "YxJrOZVToGuE"
},
"source": [
- "The resampler deals with individual examples, so you must `unbatch` the dataset before applying the resampler:"
+ "The resampling method deals with individual examples, so in this case you must `unbatch` the dataset before applying that method.\n",
+ "\n",
+ "The method needs a target distribution, and optionally an initial distribution estimate as inputs."
]
},
{
@@ -2684,7 +2665,12 @@
},
"outputs": [],
"source": [
- "resample_ds = creditcard_ds.unbatch().apply(resampler).batch(10)"
+ "resample_ds = (\n",
+ " creditcard_ds\n",
+ " .unbatch()\n",
+ " .rejection_resample(class_func, target_dist=[0.5,0.5],\n",
+ " initial_dist=fractions)\n",
+ " .batch(10))"
]
},
{
@@ -2693,7 +2679,7 @@
"id": "L-HnC1s8idqV"
},
"source": [
- "The resampler returns creates `(class, example)` pairs from the output of the `class_func`. In this case, the `example` was already a `(feature, label)` pair, so use `map` to drop the extra copy of the labels:"
+ "The `rejection_resample` method returns `(class, example)` pairs where the `class` is the output of the `class_func`. In this case, the `example` was already a `(feature, label)` pair, so use `map` to drop the extra copy of the labels:"
]
},
{
@@ -2713,7 +2699,7 @@
"id": "j3d2jyEhx9kD"
},
"source": [
- "Now the dataset produces examples of each class with 50/50 probability:"
+ "Now the dataset produces examples of each class with a 50/50 probability:"
]
},
{
@@ -2743,7 +2729,7 @@
"id": "SOGg1UFhUE4z"
},
"source": [
- "Tensorflow supports [taking checkpoints](https://www.tensorflow.org/guide/checkpoint) so that when your training process restarts it can restore the latest checkpoint to recover most of its progress. In addition to checkpointing the model variables, you can also checkpoint the progress of the dataset iterator. This could be useful if you have a large dataset and don't want to start the dataset from the beginning on each restart. Note however that iterator checkpoints may be large, since transformations such as `shuffle` and `prefetch` require buffering elements within the iterator. \n",
+ "Tensorflow supports [taking checkpoints](./checkpoint.ipynb) so that when your training process restarts it can restore the latest checkpoint to recover most of its progress. In addition to checkpointing the model variables, you can also checkpoint the progress of the dataset iterator. This could be useful if you have a large dataset and don't want to start the dataset from the beginning on each restart. Note however that iterator checkpoints may be large, since transformations such as `Dataset.shuffle` and `Dataset.prefetch` require buffering elements within the iterator.\n",
"\n",
"To include your iterator in a checkpoint, pass the iterator to the `tf.train.Checkpoint` constructor."
]
@@ -2779,7 +2765,7 @@
"id": "gxWglTwX9Fex"
},
"source": [
- "Note: It is not possible to checkpoint an iterator which relies on external state such as a `tf.py_function`. Attempting to do so will raise an exception complaining about the external state."
+ "Note: It is not possible to checkpoint an iterator which relies on an external state, such as a `tf.py_function`. Attempting to do so will raise an exception complaining about the external state."
]
},
{
@@ -2788,7 +2774,7 @@
"id": "uLRdedPpbDdD"
},
"source": [
- "## Using tf.data with tf.keras"
+ "## Using `tf.data` with `tf.keras`"
]
},
{
@@ -2798,7 +2784,7 @@
},
"source": [
"The `tf.keras` API simplifies many aspects of creating and executing machine\n",
- "learning models. Its `.fit()` and `.evaluate()` and `.predict()` APIs support datasets as inputs. Here is a quick dataset and model setup:"
+ "learning models. Its `Model.fit` and `Model.evaluate` and `Model.predict` APIs support datasets as inputs. Here is a quick dataset and model setup:"
]
},
{
@@ -2833,7 +2819,7 @@
"])\n",
"\n",
"model.compile(optimizer='adam',\n",
- " loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), \n",
+ " loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n",
" metrics=['accuracy'])"
]
},
@@ -2863,7 +2849,7 @@
"id": "FzpAQfJMJF41"
},
"source": [
- "If you pass an infinite dataset, for example by calling `Dataset.repeat()`, you just need to also pass the `steps_per_epoch` argument:"
+ "If you pass an infinite dataset, for example by calling `Dataset.repeat`, you just need to also pass the `steps_per_epoch` argument:"
]
},
{
@@ -2927,7 +2913,7 @@
"id": "aZYhJ_YSIl6w"
},
"source": [
- "The labels are not required in when calling `Model.predict`. "
+ "The labels are not required when calling `Model.predict`."
]
},
{
@@ -2967,8 +2953,8 @@
],
"metadata": {
"colab": {
- "collapsed_sections": [],
"name": "data.ipynb",
+ "provenance": [],
"toc_visible": true
},
"kernelspec": {
diff --git a/site/en/guide/data_performance.ipynb b/site/en/guide/data_performance.ipynb
index 78427505020..81d8b3fd5b3 100644
--- a/site/en/guide/data_performance.ipynb
+++ b/site/en/guide/data_performance.ipynb
@@ -274,6 +274,8 @@
"source": [
"### Prefetching\n",
"\n",
+ "\n",
+ "\n",
"Prefetching overlaps the preprocessing and model execution of a training step.\n",
"While the model is executing training step `s`, the input pipeline is reading the data for step `s+1`.\n",
"Doing so reduces the step time to the maximum (as opposed to the sum) of the training and the time it takes to extract the data.\n",
@@ -321,6 +323,8 @@
"source": [
"### Parallelizing data extraction\n",
"\n",
+ "\n",
+ "\n",
"In a real-world setting, the input data may be stored remotely (for example, on Google Cloud Storage or HDFS).\n",
"A dataset pipeline that works well when reading data locally might become bottlenecked on I/O when reading data remotely because of the following differences between local and remote storage:\n",
"\n",
@@ -420,6 +424,8 @@
"source": [
"### Parallelizing data transformation\n",
"\n",
+ "\n",
+ "\n",
"When preparing data, input elements may need to be pre-processed.\n",
"To this end, the `tf.data` API offers the `tf.data.Dataset.map` transformation, which applies a user-defined function to each element of the input dataset.\n",
"Because input elements are independent of one another, the pre-processing can be parallelized across multiple CPU cores.\n",
@@ -527,6 +533,8 @@
"source": [
"### Caching\n",
"\n",
+ "\n",
+ "\n",
"The `tf.data.Dataset.cache` transformation can cache a dataset, either in memory or on local storage.\n",
"This will save some operations (like file opening and data reading) from being executed during each epoch."
]
@@ -572,6 +580,8 @@
"source": [
"### Vectorizing mapping\n",
"\n",
+ "\n",
+ "\n",
"Invoking a user-defined function passed into the `map` transformation has overhead related to scheduling and executing the user-defined function.\n",
"Vectorize the user-defined function (that is, have it operate over a batch of inputs at once) and apply the `batch` transformation _before_ the `map` transformation.\n",
"\n",
@@ -687,6 +697,8 @@
"source": [
"### Reducing memory footprint\n",
"\n",
+ "\n",
+ "\n",
"A number of transformations, including `interleave`, `prefetch`, and `shuffle`, maintain an internal buffer of elements. If the user-defined function passed into the `map` transformation changes the size of the elements, then the ordering of the map transformation and the transformations that buffer elements affects the memory usage. In general, choose the order that results in lower memory footprint, unless different ordering is desirable for performance.\n",
"\n",
"#### Caching partial computations\n",
@@ -713,12 +725,12 @@
"Here is a summary of the best practices for designing performant TensorFlow\n",
"input pipelines:\n",
"\n",
- "* [Use the `prefetch` transformation](#Pipelining) to overlap the work of a producer and consumer\n",
- "* [Parallelize the data reading transformation](#Parallelizing-data-extraction) using the `interleave` transformation\n",
- "* [Parallelize the `map` transformation](#Parallelizing-data-transformation) by setting the `num_parallel_calls` argument\n",
- "* [Use the `cache` transformation](#Caching) to cache data in memory during the first epoch\n",
- "* [Vectorize user-defined functions](#Map-and-batch) passed in to the `map` transformation\n",
- "* [Reduce memory usage](#Reducing-memory-footprint) when applying the `interleave`, `prefetch`, and `shuffle` transformations"
+ "* [Use the `prefetch` transformation](#prefetching) to overlap the work of a producer and consumer\n",
+ "* [Parallelize the data reading transformation](#parallelizing_data_extraction) using the `interleave` transformation\n",
+ "* [Parallelize the `map` transformation](#parallelizing_data_transformation) by setting the `num_parallel_calls` argument\n",
+ "* [Use the `cache` transformation](#caching) to cache data in memory during the first epoch\n",
+ "* [Vectorize user-defined functions](#vectorizing_mapping) passed in to the `map` transformation\n",
+ "* [Reduce memory usage](#reducing_memory_footprint) when applying the `interleave`, `prefetch`, and `shuffle` transformations"
]
},
{
@@ -1153,7 +1165,6 @@
"colab": {
"collapsed_sections": [],
"name": "data_performance.ipynb",
- "provenance": [],
"toc_visible": true
},
"kernelspec": {
diff --git a/site/en/guide/distributed_training.ipynb b/site/en/guide/distributed_training.ipynb
index 6a0c72f3207..04b7118b1f2 100644
--- a/site/en/guide/distributed_training.ipynb
+++ b/site/en/guide/distributed_training.ipynb
@@ -78,7 +78,7 @@
"* Provide good performance out of the box.\n",
"* Easy switching between strategies.\n",
"\n",
- "You can distribute training using `tf.distribute.Strategy` with a high-level API like Keras `Model.fit`, as well as [custom training loops](keras/writing_a_training_loop_from_scratch.ipynb) (and, in general, any computation using TensorFlow).\n",
+ "You can distribute training using `tf.distribute.Strategy` with a high-level API like Keras `Model.fit`, as well as [custom training loops](https://www.tensorflow.org/guide/keras/writing_a_training_loop_from_scratch) (and, in general, any computation using TensorFlow).\n",
"\n",
"In TensorFlow 2.x, you can execute your programs eagerly, or in a graph using [`tf.function`](function.ipynb). `tf.distribute.Strategy` intends to support both these modes of execution, but works best with `tf.function`. Eager mode is only recommended for debugging purposes and not supported for `tf.distribute.TPUStrategy`. Although training is the focus of this guide, this API can also be used for distributing evaluation and prediction on different platforms.\n",
"\n",
@@ -130,7 +130,7 @@
"| **Custom training loop** | Supported | Supported | Supported | Experimental support | Experimental support |\n",
"| **Estimator API** | Limited Support | Not supported | Limited Support | Limited Support | Limited Support |\n",
"\n",
- "Note: [Experimental support](https://www.tensorflow.org/guide/versions#what_is_not_covered) means the APIs are not covered by any compatibilities guarantees.\n",
+ "Note: [Experimental support](https://www.tensorflow.org/guide/versions#what_is_not_covered) means the APIs are not covered by any compatibility guarantees.\n",
"\n",
"Warning: Estimator support is limited. Basic training and evaluation are experimental, and advanced features—such as scaffold—are not implemented. You should be using Keras or custom training loops if a use case is not covered. Estimators are not recommended for new code. Estimators run `v1.Session`-style code which is more difficult to write correctly, and can behave unexpectedly, especially when combined with TF 2 code. Estimators do fall under our [compatibility guarantees](https://tensorflow.org/guide/versions), but will receive no fixes other than security vulnerabilities. Go to the [migration guide](https://tensorflow.org/guide/migrate) for details."
]
@@ -421,7 +421,7 @@
"source": [
"This strategy serves two main purposes:\n",
"\n",
- "* It allows writing distribution-aware library code unconditionally. For example, in `tf.optimizer`s you can use `tf.distribute.get_strategy` and use that strategy for reducing gradients—it will always return a strategy object on which you can call the `Strategy.reduce` API.\n"
+ "* It allows writing distribution-aware library code unconditionally. For example, in `tf.keras.optimizers` you can use `tf.distribute.get_strategy` and use that strategy for reducing gradients—it will always return a strategy object on which you can call the `Strategy.reduce` API.\n"
]
},
{
@@ -503,14 +503,14 @@
"source": [
"## Use tf.distribute.Strategy with Keras Model.fit\n",
"\n",
- "`tf.distribute.Strategy` is integrated into `tf.keras`, which is TensorFlow's implementation of the [Keras API specification](https://keras.io). `tf.keras` is a high-level API to build and train models. By integrating into the `tf.keras` backend, it's seamless for you to distribute your training written in the Keras training framework [using Model.fit](/keras/customizing_what_happens_in_fit.ipynb).\n",
+ "`tf.distribute.Strategy` is integrated into `tf.keras`, which is TensorFlow's implementation of the [Keras API specification](https://keras.io/api/). `tf.keras` is a high-level API to build and train models. By integrating into the `tf.keras` backend, it's seamless for you to distribute your training written in the Keras training framework [using Model.fit](https://www.tensorflow.org/guide/keras/customizing_what_happens_in_fit).\n",
"\n",
"Here's what you need to change in your code:\n",
"\n",
"1. Create an instance of the appropriate `tf.distribute.Strategy`.\n",
- "2. Move the creation of Keras model, optimizer and metrics inside `strategy.scope`.\n",
+ "2. Move the creation of Keras model, optimizer and metrics inside `strategy.scope`. Thus the code in the model's `call()`, `train_step()`, and `test_step()` methods will all be distributed and executed on the accelerator(s).\n",
"\n",
- "TensorFlow distribution strategies support all types of Keras models—[Sequential](/keras/sequential_model.ipynb), [Functional](/keras/functional.ipynb), and [subclassed](/keras/custom_layers_and_models.ipynb).\n",
+ "TensorFlow distribution strategies support all types of Keras models—[Sequential](https://www.tensorflow.org/guide/keras/sequential_model), [Functional](https://www.tensorflow.org/guide/keras/functional), and [subclassed](https://www.tensorflow.org/guide/keras/custom_layers_and_models)\n",
"\n",
"Here is a snippet of code to do this for a very simple Keras model with one `Dense` layer:"
]
@@ -526,9 +526,10 @@
"mirrored_strategy = tf.distribute.MirroredStrategy()\n",
"\n",
"with mirrored_strategy.scope():\n",
- " model = tf.keras.Sequential([tf.keras.layers.Dense(1, input_shape=(1,))])\n",
- "\n",
- "model.compile(loss='mse', optimizer='sgd')"
+ " model = tf.keras.Sequential([\n",
+ " tf.keras.layers.Dense(1, input_shape=(1,),\n",
+ " kernel_regularizer=tf.keras.regularizers.L2(1e-4))])\n",
+ " model.compile(loss='mse', optimizer='sgd')"
]
},
{
@@ -585,6 +586,17 @@
"In both cases—with `Dataset` or NumPy—each batch of the given input is divided equally among the multiple replicas. For instance, if you are using the `MirroredStrategy` with 2 GPUs, each batch of size 10 will be divided among the 2 GPUs, with each receiving 5 input examples in each step. Each epoch will then train faster as you add more GPUs. Typically, you would want to increase your batch size as you add more accelerators, so as to make effective use of the extra computing power. You will also need to re-tune your learning rate, depending on the model. You can use `strategy.num_replicas_in_sync` to get the number of replicas."
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "8ZmJqErtS4A1"
+ },
+ "outputs": [],
+ "source": [
+ "mirrored_strategy.num_replicas_in_sync"
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
@@ -600,7 +612,7 @@
"dataset = tf.data.Dataset.from_tensors(([1.], [1.])).repeat(100)\n",
"dataset = dataset.batch(global_batch_size)\n",
"\n",
- "LEARNING_RATES_BY_BATCH_SIZE = {5: 0.1, 10: 0.15}\n",
+ "LEARNING_RATES_BY_BATCH_SIZE = {5: 0.1, 10: 0.15, 20:0.175}\n",
"learning_rate = LEARNING_RATES_BY_BATCH_SIZE[global_batch_size]"
]
},
@@ -636,7 +648,7 @@
"source": [
"## Use tf.distribute.Strategy with custom training loops\n",
"\n",
- "As demonstrated above, using `tf.distribute.Strategy` with Keras `Model.fit` requires changing only a couple lines of your code. With a little more effort, you can also use `tf.distribute.Strategy` [with custom training loops](/keras/writing_a_training_loop_from_scratch.ipynb).\n",
+ "As demonstrated above, using `tf.distribute.Strategy` with Keras `Model.fit` requires changing only a couple lines of your code. With a little more effort, you can also use `tf.distribute.Strategy` [with custom training loops](https://www.tensorflow.org/guide/keras/writing_a_training_loop_from_scratch).\n",
"\n",
"If you need more flexibility and control over your training loops than is possible with Estimator or Keras, you can write custom training loops. For instance, when using a GAN, you may want to take a different number of generator or discriminator steps each round. Similarly, the high level frameworks are not very suitable for Reinforcement Learning training.\n",
"\n",
@@ -663,7 +675,9 @@
"outputs": [],
"source": [
"with mirrored_strategy.scope():\n",
- " model = tf.keras.Sequential([tf.keras.layers.Dense(1, input_shape=(1,))])\n",
+ " model = tf.keras.Sequential([\n",
+ " tf.keras.layers.Dense(1, input_shape=(1,),\n",
+ " kernel_regularizer=tf.keras.regularizers.L2(1e-4))])\n",
" optimizer = tf.keras.optimizers.SGD()"
]
},
@@ -684,7 +698,7 @@
},
"outputs": [],
"source": [
- "dataset = tf.data.Dataset.from_tensors(([1.], [1.])).repeat(100).batch(\n",
+ "dataset = tf.data.Dataset.from_tensors(([1.], [1.])).repeat(1000).batch(\n",
" global_batch_size)\n",
"dist_dataset = mirrored_strategy.experimental_distribute_dataset(dataset)"
]
@@ -706,20 +720,21 @@
},
"outputs": [],
"source": [
+ "# Sets `reduction=NONE` to leave it to tf.nn.compute_average_loss() below.\n",
"loss_object = tf.keras.losses.BinaryCrossentropy(\n",
" from_logits=True,\n",
" reduction=tf.keras.losses.Reduction.NONE)\n",
"\n",
- "def compute_loss(labels, predictions):\n",
- " per_example_loss = loss_object(labels, predictions)\n",
- " return tf.nn.compute_average_loss(per_example_loss, global_batch_size=global_batch_size)\n",
- "\n",
"def train_step(inputs):\n",
" features, labels = inputs\n",
"\n",
" with tf.GradientTape() as tape:\n",
" predictions = model(features, training=True)\n",
- " loss = compute_loss(labels, predictions)\n",
+ " per_example_loss = loss_object(labels, predictions)\n",
+ " loss = tf.nn.compute_average_loss(per_example_loss)\n",
+ " model_losses = model.losses\n",
+ " if model_losses:\n",
+ " loss += tf.nn.scale_regularization_loss(tf.add_n(model_losses))\n",
"\n",
" gradients = tape.gradient(loss, model.trainable_variables)\n",
" optimizer.apply_gradients(zip(gradients, model.trainable_variables))\n",
@@ -740,9 +755,16 @@
"source": [
"A few other things to note in the code above:\n",
"\n",
- "1. You used `tf.nn.compute_average_loss` to compute the loss. `tf.nn.compute_average_loss` sums the per example loss and divides the sum by the `global_batch_size`. This is important because later after the gradients are calculated on each replica, they are aggregated across the replicas by **summing** them.\n",
- "2. You also used the `tf.distribute.Strategy.reduce` API to aggregate the results returned by `tf.distribute.Strategy.run`. `tf.distribute.Strategy.run` returns results from each local replica in the strategy, and there are multiple ways to consume this result. You can `reduce` them to get an aggregated value. You can also do `tf.distribute.Strategy.experimental_local_results` to get the list of values contained in the result, one per local replica.\n",
- "3. When you call `apply_gradients` within a distribution strategy scope, its behavior is modified. Specifically, before applying gradients on each parallel instance during synchronous training, it performs a sum-over-all-replicas of the gradients.\n"
+ " 1. You used `tf.nn.compute_average_loss` to reduce the per-example prediction losses to a scalar. `tf.nn.compute_average_loss` sums the per example loss and divides the sum by the global batch size. This is important because later after the gradients are calculated on each replica, they are aggregated across the replicas by **summing** them.\n",
+ "\n",
+ " By default, the global batch size is taken to be `tf.get_strategy().num_replicas_in_sync * tf.shape(per_example_loss)[0]`. It can also be specified explicitly as a keyword argument `global_batch_size=`. Without short batches, the default is equivalent to `tf.nn.compute_average_loss(..., global_batch_size=global_batch_size)` with the `global_batch_size` defined above. (For more on short batches and how to avoid or handle them, see the [Custom Training tutorial](../tutorials/distribute/custom_training.ipynb).)\n",
+ "\n",
+ " 2. You used `tf.nn.scale_regularization_loss` to scale regularization losses registered with the `Model` object, if any, by `1/num_replicas_in_sync` as well. For those regularization losses that are input-dependent, it falls on the modeling code, not the custom training loop, to perform the averaging over the per-replica(!) batch size; that way the modeling code can remain agnostic of replication while the training loop remains agnostic of how regularization losses are computed.\n",
+ "\n",
+ " 3. When you call `apply_gradients` within a distribution strategy scope, its behavior is modified. Specifically, before applying gradients on each parallel instance during synchronous training, it performs a sum-over-all-replicas of the gradients.\n",
+ "\n",
+ " 4. You also used the `tf.distribute.Strategy.reduce` API to aggregate the results returned by `tf.distribute.Strategy.run` for reporting. `tf.distribute.Strategy.run` returns results from each local replica in the strategy, and there are multiple ways to consume this result. You can `reduce` them to get an aggregated value. You can also do `tf.distribute.Strategy.experimental_local_results` to get the list of values contained in the result, one per local replica.\n",
+ "\n"
]
},
{
diff --git a/site/en/guide/dtensor_overview.ipynb b/site/en/guide/dtensor_overview.ipynb
new file mode 100644
index 00000000000..1b55ee0283f
--- /dev/null
+++ b/site/en/guide/dtensor_overview.ipynb
@@ -0,0 +1,1082 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "1ljvLya59ep5"
+ },
+ "source": [
+ "##### Copyright 2019 The TensorFlow Authors.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "cellView": "form",
+ "id": "tuOe1ymfHZPu"
+ },
+ "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": {
+ "id": "VcQIa1uG86Wh"
+ },
+ "source": [
+ "# DTensor concepts"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "6dWNQEum9AfY"
+ },
+ "source": [
+ "\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
\n",
- " ![]() | \n",
- " \n",
- " ![]() | \n",
- " \n",
- " ![]() | \n",
- " \n",
- " ![]() | \n",
- "
\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "
\n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ " \n",
+ " ![]() | \n",
+ "