From 53f3748426001e4be9923a25f9f3394707f4e206 Mon Sep 17 00:00:00 2001 From: Susheel Thapa Date: Fri, 20 Oct 2023 06:35:15 +0545 Subject: [PATCH 01/10] Chore: Fix the typo in multiple files --- site/en/community/contribute/docs_style.md | 2 +- site/en/guide/migrate/evaluator.ipynb | 2 +- site/en/guide/sparse_tensor.ipynb | 7 ++++++- site/en/guide/tf_numpy_type_promotion.ipynb | 5 +++-- site/en/hub/tutorials/boundless.ipynb | 2 +- site/en/hub/tutorials/s3gan_generation_with_tf_hub.ipynb | 2 +- site/en/hub/tutorials/tf2_object_detection.ipynb | 2 +- site/en/hub/tutorials/wiki40b_lm.ipynb | 2 +- site/en/r1/guide/autograph.ipynb | 2 +- site/en/r1/guide/distribute_strategy.ipynb | 6 +++--- site/en/r1/tutorials/representation/unicode.ipynb | 4 ++-- 11 files changed, 21 insertions(+), 15 deletions(-) diff --git a/site/en/community/contribute/docs_style.md b/site/en/community/contribute/docs_style.md index eba78afa896..d4e42cb5235 100644 --- a/site/en/community/contribute/docs_style.md +++ b/site/en/community/contribute/docs_style.md @@ -63,7 +63,7 @@ repository like this: * \[Basics\]\(../../guide/basics.ipynb\) produces [Basics](../../guide/basics.ipynb). -This is the prefered approach because this way the links on +This is the preferred approach because this way the links on [tensorflow.org](https://www.tensorflow.org), [GitHub](https://github.com/tensorflow/docs){:.external} and [Colab](https://github.com/tensorflow/docs/tree/master/site/en/guide/bazics.ipynb){:.external} diff --git a/site/en/guide/migrate/evaluator.ipynb b/site/en/guide/migrate/evaluator.ipynb index fd8bd12d1e1..c8f848e4406 100644 --- a/site/en/guide/migrate/evaluator.ipynb +++ b/site/en/guide/migrate/evaluator.ipynb @@ -122,7 +122,7 @@ "\n", "In TensorFlow 1, you can configure a `tf.estimator` to evaluate the estimator using `tf.estimator.train_and_evaluate`.\n", "\n", - "In this example, start by defining the `tf.estimator.Estimator` and speciyfing training and evaluation specifications:" + "In this example, start by defining the `tf.estimator.Estimator` and specifying training and evaluation specifications:" ] }, { diff --git a/site/en/guide/sparse_tensor.ipynb b/site/en/guide/sparse_tensor.ipynb index cd38fdf55ab..407561ec6f5 100644 --- a/site/en/guide/sparse_tensor.ipynb +++ b/site/en/guide/sparse_tensor.ipynb @@ -31,6 +31,11 @@ "# limitations under the License." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "markdown", "metadata": { @@ -620,7 +625,7 @@ "\n", "However, there are a few cases where it can be useful to distinguish zero values from missing values. In particular, this allows for one way to encode missing/unknown data in your training data. For example, consider a use case where you have a tensor of scores (that can have any floating point value from -Inf to +Inf), with some missing scores. You can encode this tensor using a sparse tensor where the explicit zeros are known zero scores but the implicit zero values actually represent missing data and not zero. \n", "\n", - "Note: This is generally not the intended usage of `tf.sparse.SparseTensor`s; and you might want to also consier other techniques for encoding this such as for example using a separate mask tensor that identifies the locations of known/unknown values. However, exercise caution while using this approach, since most sparse operations will treat explicit and implicit zero values identically." + "Note: This is generally not the intended usage of `tf.sparse.SparseTensor`s; and you might want to also consider other techniques for encoding this such as for example using a separate mask tensor that identifies the locations of known/unknown values. However, exercise caution while using this approach, since most sparse operations will treat explicit and implicit zero values identically." ] }, { diff --git a/site/en/guide/tf_numpy_type_promotion.ipynb b/site/en/guide/tf_numpy_type_promotion.ipynb index a9e176c5db6..51bea78914f 100644 --- a/site/en/guide/tf_numpy_type_promotion.ipynb +++ b/site/en/guide/tf_numpy_type_promotion.ipynb @@ -178,7 +178,8 @@ "* `f32*` means Python `float` or weakly-typed `f32`\n", "* `c128*` means Python `complex` or weakly-typed `c128`\n", "\n", - "The asterik (*) denotes that the corresponding type is “weak” - such a dtype is temporarily inferred by the system, and could defer to other dtypes. This concept is explained more in detail [here](#weak_tensor)." + "The asterisk\n", + " (*) denotes that the corresponding type is “weak” - such a dtype is temporarily inferred by the system, and could defer to other dtypes. This concept is explained more in detail [here](#weak_tensor)." ] }, { @@ -449,7 +450,7 @@ "source": [ "### WeakTensor Construction\n", "\n", - "WeakTensors are created if you create a tensor without specifing a dtype the result is a WeakTensor. You can check whether a Tensor is \"weak\" or not by checking the weak attribute at the end of the Tensor's string representation." + "WeakTensors are created if you create a tensor without specifying a dtype the result is a WeakTensor. You can check whether a Tensor is \"weak\" or not by checking the weak attribute at the end of the Tensor's string representation." ] }, { diff --git a/site/en/hub/tutorials/boundless.ipynb b/site/en/hub/tutorials/boundless.ipynb index 570e9413362..4697a810bb8 100644 --- a/site/en/hub/tutorials/boundless.ipynb +++ b/site/en/hub/tutorials/boundless.ipynb @@ -271,7 +271,7 @@ "* The input image with a mask applied\n", "* The masked image with the extrapolation to complete it\n", "\n", - "we can use these two images to show a comparisson visualization." + "we can use these two images to show a comparison visualization." ] }, { diff --git a/site/en/hub/tutorials/s3gan_generation_with_tf_hub.ipynb b/site/en/hub/tutorials/s3gan_generation_with_tf_hub.ipynb index d8efd802ae0..bd73cffebdf 100644 --- a/site/en/hub/tutorials/s3gan_generation_with_tf_hub.ipynb +++ b/site/en/hub/tutorials/s3gan_generation_with_tf_hub.ipynb @@ -86,7 +86,7 @@ "2. Click **Runtime > Run all** to run each cell in order.\n", " * Afterwards, the interactive visualizations should update automatically when you modify the settings using the sliders and dropdown menus.\n", "\n", - "Note: if you run into any issues, youn can try restarting the runtime and rerunning all cells from scratch by clicking **Runtime > Restart and run all...**.\n", + "Note: if you run into any issues, you can try restarting the runtime and rerunning all cells from scratch by clicking **Runtime > Restart and run all...**.\n", "\n", "[1] Mario Lucic\\*, Michael Tschannen\\*, Marvin Ritter\\*, Xiaohua Zhai, Olivier\n", " Bachem, Sylvain Gelly, [High-Fidelity Image Generation With Fewer Labels](https://arxiv.org/abs/1903.02271), ICML 2019." diff --git a/site/en/hub/tutorials/tf2_object_detection.ipynb b/site/en/hub/tutorials/tf2_object_detection.ipynb index 38b162068d9..3793ad20485 100644 --- a/site/en/hub/tutorials/tf2_object_detection.ipynb +++ b/site/en/hub/tutorials/tf2_object_detection.ipynb @@ -291,7 +291,7 @@ "id": "yX3pb_pXDjYA" }, "source": [ - "Intalling the Object Detection API" + "Installing the Object Detection API" ] }, { diff --git a/site/en/hub/tutorials/wiki40b_lm.ipynb b/site/en/hub/tutorials/wiki40b_lm.ipynb index e696160faca..ad94ce0aab8 100644 --- a/site/en/hub/tutorials/wiki40b_lm.ipynb +++ b/site/en/hub/tutorials/wiki40b_lm.ipynb @@ -214,7 +214,7 @@ " # Generate the tokens from the language model\n", " generation_outputs = module(generation_input_dict, signature=\"prediction\", as_dict=True)\n", "\n", - " # Get the probablities and the inputs for the next steps\n", + " # Get the probabilities and the inputs for the next steps\n", " probs = generation_outputs[\"probs\"]\n", " new_mems = [generation_outputs[\"new_mem_{}\".format(i)] for i in range(n_layer)]\n", "\n", diff --git a/site/en/r1/guide/autograph.ipynb b/site/en/r1/guide/autograph.ipynb index f028b33ce9f..790dbb49df1 100644 --- a/site/en/r1/guide/autograph.ipynb +++ b/site/en/r1/guide/autograph.ipynb @@ -241,7 +241,7 @@ "id": "m-jWmsCmByyw" }, "source": [ - "AutoGraph supports common Python statements like `while`, `for`, `if`, `break`, and `return`, with support for nesting. Compare this function with the complicated graph verson displayed in the following code blocks:" + "AutoGraph supports common Python statements like `while`, `for`, `if`, `break`, and `return`, with support for nesting. Compare this function with the complicated graph version displayed in the following code blocks:" ] }, { diff --git a/site/en/r1/guide/distribute_strategy.ipynb b/site/en/r1/guide/distribute_strategy.ipynb index 79d6293eba7..cc51259b78e 100644 --- a/site/en/r1/guide/distribute_strategy.ipynb +++ b/site/en/r1/guide/distribute_strategy.ipynb @@ -118,7 +118,7 @@ "## Types of strategies\n", "`tf.distribute.Strategy` intends to cover a number of use cases along different axes. Some of these combinations are currently supported and others will be added in the future. Some of these axes are:\n", "\n", - "* Syncronous vs asynchronous training: These are two common ways of distributing training with data parallelism. In sync training, all workers train over different slices of input data in sync, and aggregating gradients at each step. In async training, all workers are independently training over the input data and updating variables asynchronously. Typically sync training is supported via all-reduce and async through parameter server architecture.\n", + "* Synchronous vs asynchronous training: These are two common ways of distributing training with data parallelism. In sync training, all workers train over different slices of input data in sync, and aggregating gradients at each step. In async training, all workers are independently training over the input data and updating variables asynchronously. Typically sync training is supported via all-reduce and async through parameter server architecture.\n", "* Hardware platform: Users may want to scale their training onto multiple GPUs on one machine, or multiple machines in a network (with 0 or more GPUs each), or on Cloud TPUs.\n", "\n", "In order to support these use cases, we have 4 strategies available. In the next section we will talk about which of these are supported in which scenarios in TF." @@ -371,7 +371,7 @@ "id": "hQv1lm9UPDFy" }, "source": [ - "So far we've talked about what are the different stategies available and how you can instantiate them. In the next few sections, we will talk about the different ways in which you can use them to distribute your training. We will show short code snippets in this guide and link off to full tutorials which you can run end to end." + "So far we've talked about what are the different strategies available and how you can instantiate them. In the next few sections, we will talk about the different ways in which you can use them to distribute your training. We will show short code snippets in this guide and link off to full tutorials which you can run end to end." ] }, { @@ -595,7 +595,7 @@ "### Examples and Tutorials\n", "Here are some examples that show end to end usage of various strategies with Estimator:\n", "\n", - "1. [End to end example](https://github.com/tensorflow/ecosystem/tree/master/distribution_strategy) for multi worker training in tensorflow/ecosystem using Kuberentes templates. This example starts with a Keras model and converts it to an Estimator using the `tf.keras.estimator.model_to_estimator` API.\n", + "1. [End to end example](https://github.com/tensorflow/ecosystem/tree/master/distribution_strategy) for multi worker training in tensorflow/ecosystem using Kubernetes templates. This example starts with a Keras model and converts it to an Estimator using the `tf.keras.estimator.model_to_estimator` API.\n", "2. Official [ResNet50](https://github.com/tensorflow/models/blob/master/official/r1/resnet/imagenet_main.py) model, which can be trained using either `MirroredStrategy` or `MultiWorkerMirroredStrategy`.\n", "3. [ResNet50](https://github.com/tensorflow/tpu/blob/master/models/experimental/distribution_strategy/resnet_estimator.py) example with TPUStrategy." ] diff --git a/site/en/r1/tutorials/representation/unicode.ipynb b/site/en/r1/tutorials/representation/unicode.ipynb index 98aaacff5b9..301a64d72fc 100644 --- a/site/en/r1/tutorials/representation/unicode.ipynb +++ b/site/en/r1/tutorials/representation/unicode.ipynb @@ -136,7 +136,7 @@ "id": "jsMPnjb6UDJ1" }, "source": [ - "Note: When using python to construct strings, the handling of unicode differs betweeen v2 and v3. In v2, unicode strings are indicated by the \"u\" prefix, as above. In v3, strings are unicode-encoded by default." + "Note: When using python to construct strings, the handling of unicode differs between v2 and v3. In v2, unicode strings are indicated by the \"u\" prefix, as above. In v3, strings are unicode-encoded by default." ] }, { @@ -587,7 +587,7 @@ "id": "CapnbShuGU8i" }, "source": [ - "First, we decode the sentences into character codepoints, and find the script identifeir for each character." + "First, we decode the sentences into character codepoints, and find the script identifier for each character." ] }, { From 57e7adb5be0b912a6efa4b9f1e81694e616d0c87 Mon Sep 17 00:00:00 2001 From: 8bitmp3 <19637339+8bitmp3@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:12:40 +0000 Subject: [PATCH 02/10] Update site/en/guide/tf_numpy_type_promotion.ipynb --- site/en/guide/tf_numpy_type_promotion.ipynb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/site/en/guide/tf_numpy_type_promotion.ipynb b/site/en/guide/tf_numpy_type_promotion.ipynb index 51bea78914f..1b0f6d116c8 100644 --- a/site/en/guide/tf_numpy_type_promotion.ipynb +++ b/site/en/guide/tf_numpy_type_promotion.ipynb @@ -178,8 +178,7 @@ "* `f32*` means Python `float` or weakly-typed `f32`\n", "* `c128*` means Python `complex` or weakly-typed `c128`\n", "\n", - "The asterisk\n", - " (*) denotes that the corresponding type is “weak” - such a dtype is temporarily inferred by the system, and could defer to other dtypes. This concept is explained more in detail [here](#weak_tensor)." + "The asterisk (*) denotes that the corresponding type is “weak” - such a dtype is temporarily inferred by the system, and could defer to other dtypes. This concept is explained more in detail [here](#weak_tensor)." ] }, { From 2c5c356edfe1f80070ee8bc1d9956cad612cecb6 Mon Sep 17 00:00:00 2001 From: 8bitmp3 <19637339+8bitmp3@users.noreply.github.com> Date: Tue, 19 Dec 2023 23:36:54 +0000 Subject: [PATCH 03/10] Update site/en/guide/sparse_tensor.ipynb --- site/en/guide/sparse_tensor.ipynb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/site/en/guide/sparse_tensor.ipynb b/site/en/guide/sparse_tensor.ipynb index 407561ec6f5..45f1e3fd3c3 100644 --- a/site/en/guide/sparse_tensor.ipynb +++ b/site/en/guide/sparse_tensor.ipynb @@ -31,11 +31,6 @@ "# limitations under the License." ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, { "cell_type": "markdown", "metadata": { From 8b36191001b53bfce4fe15b77e243fbd7f382e41 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 13 Feb 2024 22:56:26 -0800 Subject: [PATCH 04/10] Generate just one seed, rather than generating two seeds and then taking the first half of each seed. rng.make_seeds(n) generates a tensor with shape (2,n): each seed is a 2-tuple. The previous code took the first half of each of two seed tuples. Instead, we generate just one 2-tuple. PiperOrigin-RevId: 606866194 --- site/en/tutorials/images/data_augmentation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/en/tutorials/images/data_augmentation.ipynb b/site/en/tutorials/images/data_augmentation.ipynb index bdc7ae0c56a..8a1eaaabec4 100644 --- a/site/en/tutorials/images/data_augmentation.ipynb +++ b/site/en/tutorials/images/data_augmentation.ipynb @@ -1273,7 +1273,7 @@ "source": [ "# Create a wrapper function for updating seeds.\n", "def f(x, y):\n", - " seed = rng.make_seeds(2)[0]\n", + " seed = rng.make_seeds(1)[:, 0]\n", " image, label = augment((x, y), seed)\n", " return image, label" ] From 065658214f9878e8e1f3c61bed3e61a6381379fc Mon Sep 17 00:00:00 2001 From: Fergus Henderson Date: Thu, 29 Feb 2024 11:06:01 -0800 Subject: [PATCH 05/10] Fix formatting error in versions.md. PiperOrigin-RevId: 611531167 --- site/en/guide/versions.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/site/en/guide/versions.md b/site/en/guide/versions.md index 5e660892b6d..0b089885552 100644 --- a/site/en/guide/versions.md +++ b/site/en/guide/versions.md @@ -171,12 +171,10 @@ incrementing the major version number for TensorFlow Lite, or vice versa. The API surface that is covered by the TensorFlow Lite Extension APIs version number is comprised of the following public APIs: -``` * [tensorflow/lite/c/c_api_opaque.h](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/c/c_api_opaque.h) * [tensorflow/lite/c/common.h](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/c/common.h) * [tensorflow/lite/c/builtin_op_data.h](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/c/builtin_op_data.h) * [tensorflow/lite/builtin_ops.h](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/builtin_ops.h) -``` Again, experimental symbols are not covered; see [below](#not_covered) for details. From 350b22d2bbb8d9aab686a6f6c8a066ce1ddad2f7 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 5 Mar 2024 16:22:33 -0800 Subject: [PATCH 06/10] Add Tensorflow 2.16 tested build configurations PiperOrigin-RevId: 613006193 --- site/en/install/source.md | 21 +++++++++++++-------- site/en/install/source_windows.md | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/site/en/install/source.md b/site/en/install/source.md index 0c556810fad..765be347f8a 100644 --- a/site/en/install/source.md +++ b/site/en/install/source.md @@ -60,7 +60,7 @@ file. Clang is a C/C++/Objective-C compiler that is compiled in C++ based on LLVM. It is the default compiler to build TensorFlow starting with TensorFlow 2.13. The -current supported version is LLVM/Clang 16. +current supported version is LLVM/Clang 17. [LLVM Debian/Ubuntu nightly packages](https://apt.llvm.org) provide an automatic installation script and packages for manual installation on Linux. Make sure you @@ -68,22 +68,24 @@ run the following command if you manually add llvm apt repository to your package sources:
-sudo apt-get update && sudo apt-get install -y llvm-16 clang-16
+sudo apt-get update && sudo apt-get install -y llvm-17 clang-17
 
+Now that `/usr/lib/llvm-17/bin/clang` is the actual path to clang in this case. + Alternatively, you can download and unpack the pre-built -[Clang + LLVM 16](https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.0). +[Clang + LLVM 17](https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.2). Below is an example of steps you can take to set up the downloaded Clang + LLVM -16 binaries on Debian/Ubuntu operating systems: +17 binaries on Debian/Ubuntu operating systems: 1. Change to the desired destination directory: `cd ` 1. Load and extract an archive file...(suitable to your architecture):
-    wget https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
+    wget https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.2/clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04.tar.xz
     
-    tar -xvf clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
+    tar -xvf clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04.tar.xz
     
     
@@ -93,10 +95,10 @@ Below is an example of steps you can take to set up the downloaded Clang + LLVM have to replace anything, unless you have a previous installation, in which case you should replace the files:
-    cp -r clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/* /usr
+    cp -r clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04/* /usr
     
-1. Check the obtained Clang + LLVM 16 binaries version: +1. Check the obtained Clang + LLVM 17 binaries version:
     clang --version
     
@@ -430,6 +432,7 @@ Success: TensorFlow is now installed. + @@ -468,6 +471,7 @@ Success: TensorFlow is now installed.
VersionPython versionCompilerBuild tools
tensorflow-2.16.13.9-3.12Clang 17.0.1Bazel 6.5.0
tensorflow-2.15.03.9-3.11Clang 16.0.0Bazel 6.1.0
tensorflow-2.14.03.9-3.11Clang 16.0.0Bazel 6.1.0
tensorflow-2.13.03.8-3.11Clang 16.0.0Bazel 5.3.0
+ @@ -508,6 +512,7 @@ Success: TensorFlow is now installed.
VersionPython versionCompilerBuild toolscuDNNCUDA
tensorflow-2.16.13.9-3.12Clang 17.0.1Bazel 6.5.08.912.3
tensorflow-2.15.03.9-3.11Clang 16.0.0Bazel 6.1.08.912.2
tensorflow-2.14.03.9-3.11Clang 16.0.0Bazel 6.1.08.711.8
tensorflow-2.13.03.8-3.11Clang 16.0.0Bazel 5.3.08.611.8
+ diff --git a/site/en/install/source_windows.md b/site/en/install/source_windows.md index 758e5dbea45..7a600947ad4 100644 --- a/site/en/install/source_windows.md +++ b/site/en/install/source_windows.md @@ -309,6 +309,7 @@ Note: Starting in TF 2.11, CUDA build is not supported for Windows. For using Te
VersionPython versionCompilerBuild tools
tensorflow-2.16.13.9-3.12Clang from xcode 13.6Bazel 6.5.0
tensorflow-2.15.03.9-3.11Clang from xcode 10.15Bazel 6.1.0
tensorflow-2.14.03.9-3.11Clang from xcode 10.15Bazel 6.1.0
tensorflow-2.13.03.8-3.11Clang from xcode 10.15Bazel 5.3.0
+ From 57a0d991e684cd01cec3ac152112a7df3a18a26a Mon Sep 17 00:00:00 2001 From: Kanglan Tang Date: Wed, 6 Mar 2024 09:33:21 -0800 Subject: [PATCH 07/10] Update Clang version to 17.0.6 for TF 2.16 in tested build configurations PiperOrigin-RevId: 613244520 --- site/en/install/source.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/en/install/source.md b/site/en/install/source.md index 765be347f8a..d841b8ff9b4 100644 --- a/site/en/install/source.md +++ b/site/en/install/source.md @@ -432,7 +432,7 @@ Success: TensorFlow is now installed.
VersionPython versionCompilerBuild tools
tensorflow-2.16.13.9-3.12MSVC 2019Bazel 6.5.0
tensorflow-2.15.03.9-3.11MSVC 2019Bazel 6.1.0
tensorflow-2.14.03.9-3.11MSVC 2019Bazel 6.1.0
tensorflow-2.12.03.8-3.11MSVC 2019Bazel 5.3.0
- + @@ -471,7 +471,7 @@ Success: TensorFlow is now installed.
VersionPython versionCompilerBuild tools
tensorflow-2.16.13.9-3.12Clang 17.0.1Bazel 6.5.0
tensorflow-2.16.13.9-3.12Clang 17.0.6Bazel 6.5.0
tensorflow-2.15.03.9-3.11Clang 16.0.0Bazel 6.1.0
tensorflow-2.14.03.9-3.11Clang 16.0.0Bazel 6.1.0
tensorflow-2.13.03.8-3.11Clang 16.0.0Bazel 5.3.0
- + From 3688f3cff2685cfeab307c13435f77d2c96cf434 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 8 Mar 2024 10:48:15 -0800 Subject: [PATCH 08/10] Update docs for building from source PiperOrigin-RevId: 613981262 --- site/en/install/source.md | 70 +++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/site/en/install/source.md b/site/en/install/source.md index d841b8ff9b4..6a0aa08ed4b 100644 --- a/site/en/install/source.md +++ b/site/en/install/source.md @@ -34,8 +34,7 @@ Install the TensorFlow *pip* package dependencies (if using a virtual environment, omit the `--user` argument):
-pip install -U --user pip numpy wheel packaging requests opt_einsum
-pip install -U --user keras_preprocessing --no-deps
+pip install -U --user pip
 
Note: A `pip` version >19.0 is required to install the TensorFlow 2 `.whl` @@ -242,19 +241,6 @@ There are some preconfigured build configs available that can be added to the ## Build and install the pip package -The pip package is build in two steps. A `bazel build` commands creates a -"package-builder" program. You then run the package-builder to create the -package. - -### Build the package-builder -Note: GPU support can be enabled with `cuda=Y` during the `./configure` stage. - -Use `bazel build` to create the TensorFlow 2.x package-builder: - -
-bazel build [--config=option] //tensorflow/tools/pip_package:build_pip_package
-
- #### Bazel build options Refer to the Bazel @@ -270,25 +256,34 @@ that complies with the manylinux2014 package standard. ### Build the package -The `bazel build` command creates an executable named `build_pip_package`—this -is the program that builds the `pip` package. Run the executable as shown -below to build a `.whl` package in the `/tmp/tensorflow_pkg` directory. +To build pip package, you need to specify `--repo_env=WHEEL_NAME` flag. +depending on the provided name, package will be created, e.g: -To build from a release branch: +To build tensorflow CPU package: +
+bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow_cpu
+
+To build tensorflow GPU package:
-./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
+bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow --config=cuda
 
-To build from master, use `--nightly_flag` to get the right dependencies: +To build tensorflow TPU package: +
+bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow_tpu --config=tpu
+
+To build nightly package, set `tf_nightly` instead of `tensorflow`, e.g. +to build CPU nightly package:
-./bazel-bin/tensorflow/tools/pip_package/build_pip_package --nightly_flag /tmp/tensorflow_pkg
+bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tf_nightly_cpu
 
-Although it is possible to build both CUDA and non-CUDA configurations under the -same source tree, it's recommended to run `bazel clean` when switching between -these two configurations in the same source tree. +As a result, generated wheel will be located in +
+bazel-bin/tensorflow/tools/pip_package/wheel_house/
+
### Install the package @@ -296,7 +291,7 @@ The filename of the generated `.whl` file depends on the TensorFlow version and your platform. Use `pip install` to install the package, for example:
-pip install /tmp/tensorflow_pkg/tensorflow-version-tags.whl
+pip install bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow-version-tags.whl
 
Success: TensorFlow is now installed. @@ -346,18 +341,15 @@ virtual environment: 1. Optional: Configure the build—this prompts the user to answer build configuration questions. -2. Build the tool used to create the *pip* package. -3. Run the tool to create the *pip* package. -4. Adjust the ownership permissions of the file for outside the container. +2. Build the *pip* package. +3. Adjust the ownership permissions of the file for outside the container.
 ./configure  # if necessary
 
-bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
-
-./bazel-bin/tensorflow/tools/pip_package/build_pip_package /mnt  # create package
-
-chown $HOST_PERMS /mnt/tensorflow-version-tags.whl
+bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow_cpu --config=opt
+`
+chown $HOST_PERMS bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow-version-tags.whl
 
Install and verify the package within the container: @@ -365,7 +357,7 @@ Install and verify the package within the container:
 pip uninstall tensorflow  # remove current version
 
-pip install /mnt/tensorflow-version-tags.whl
+pip install bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow-version-tags.whl
 cd /tmp  # don't import from source directory
 python -c "import tensorflow as tf; print(tf.__version__)"
 
@@ -403,11 +395,9 @@ with GPU support:
 ./configure  # if necessary
 
-bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
-
-./bazel-bin/tensorflow/tools/pip_package/build_pip_package /mnt  # create package
+bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow --config=cuda --config=opt
 
-chown $HOST_PERMS /mnt/tensorflow-version-tags.whl
+chown $HOST_PERMS bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow-version-tags.whl
 
Install and verify the package within the container and check for a GPU: @@ -415,7 +405,7 @@ Install and verify the package within the container and check for a GPU:
 pip uninstall tensorflow  # remove current version
 
-pip install /mnt/tensorflow-version-tags.whl
+pip install bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow-version-tags.whl
 cd /tmp  # don't import from source directory
 python -c "import tensorflow as tf; print(\"Num GPUs Available: \", len(tf.config.list_physical_devices('GPU')))"
 
From b64768499123da8b2253a534277d62e20de3ec73 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Tue, 12 Mar 2024 15:21:47 -0700 Subject: [PATCH 09/10] Fix notebook failure with Keras 3. PiperOrigin-RevId: 615189902 --- .../tutorials/images/transfer_learning.ipynb | 23 +-- .../tutorials/keras/text_classification.ipynb | 44 ++--- site/en/tutorials/quickstart/advanced.ipynb | 20 +- .../structured_data/time_series.ipynb | 186 ++++++++++-------- 4 files changed, 142 insertions(+), 131 deletions(-) diff --git a/site/en/tutorials/images/transfer_learning.ipynb b/site/en/tutorials/images/transfer_learning.ipynb index 6406ccdce74..30353697208 100644 --- a/site/en/tutorials/images/transfer_learning.ipynb +++ b/site/en/tutorials/images/transfer_learning.ipynb @@ -585,7 +585,7 @@ }, "outputs": [], "source": [ - "prediction_layer = tf.keras.layers.Dense(1)\n", + "prediction_layer = tf.keras.layers.Dense(1, activation='sigmoid')\n", "prediction_batch = prediction_layer(feature_batch_average)\n", "print(prediction_batch.shape)" ] @@ -667,7 +667,7 @@ "source": [ "### Compile the model\n", "\n", - "Compile the model before training it. Since there are two classes, use the `tf.keras.losses.BinaryCrossentropy` loss with `from_logits=True` since the model provides a linear output." + "Compile the model before training it. Since there are two classes and a sigmoid oputput, use the `BinaryAccuracy`." ] }, { @@ -680,8 +680,8 @@ "source": [ "base_learning_rate = 0.0001\n", "model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=base_learning_rate),\n", - " loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),\n", - " metrics=[tf.keras.metrics.BinaryAccuracy(threshold=0, name='accuracy')])" + " loss=tf.keras.losses.BinaryCrossentropy(),\n", + " metrics=[tf.keras.metrics.BinaryAccuracy(threshold=0.5, name='accuracy')])" ] }, { @@ -872,9 +872,9 @@ }, "outputs": [], "source": [ - "model.compile(loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),\n", + "model.compile(loss=tf.keras.losses.BinaryCrossentropy(),\n", " optimizer = tf.keras.optimizers.RMSprop(learning_rate=base_learning_rate/10),\n", - " metrics=[tf.keras.metrics.BinaryAccuracy(threshold=0, name='accuracy')])" + " metrics=[tf.keras.metrics.BinaryAccuracy(threshold=0.5, name='accuracy')])" ] }, { @@ -1081,22 +1081,13 @@ "\n", "To learn more, visit the [Transfer learning guide](https://www.tensorflow.org/guide/keras/transfer_learning).\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "uKIByL01da8c" - }, - "outputs": [], - "source": [] } ], "metadata": { "accelerator": "GPU", "colab": { "name": "transfer_learning.ipynb", - "private_outputs": true, + "provenance": [], "toc_visible": true }, "kernelspec": { diff --git a/site/en/tutorials/keras/text_classification.ipynb b/site/en/tutorials/keras/text_classification.ipynb index f14964207ff..c66d0fce0d3 100644 --- a/site/en/tutorials/keras/text_classification.ipynb +++ b/site/en/tutorials/keras/text_classification.ipynb @@ -267,9 +267,9 @@ "id": "95kkUdRoaeMw" }, "source": [ - "Next, you will use the `text_dataset_from_directory` utility to create a labeled `tf.data.Dataset`. [tf.data](https://www.tensorflow.org/guide/data) is a powerful collection of tools for working with data. \n", + "Next, you will use the `text_dataset_from_directory` utility to create a labeled `tf.data.Dataset`. [tf.data](https://www.tensorflow.org/guide/data) is a powerful collection of tools for working with data.\n", "\n", - "When running a machine learning experiment, it is a best practice to divide your dataset into three splits: [train](https://developers.google.com/machine-learning/glossary#training_set), [validation](https://developers.google.com/machine-learning/glossary#validation_set), and [test](https://developers.google.com/machine-learning/glossary#test-set). \n", + "When running a machine learning experiment, it is a best practice to divide your dataset into three splits: [train](https://developers.google.com/machine-learning/glossary#training_set), [validation](https://developers.google.com/machine-learning/glossary#validation_set), and [test](https://developers.google.com/machine-learning/glossary#test-set).\n", "\n", "The IMDB dataset has already been divided into train and test, but it lacks a validation set. Let's create a validation set using an 80:20 split of the training data by using the `validation_split` argument below." ] @@ -286,10 +286,10 @@ "seed = 42\n", "\n", "raw_train_ds = tf.keras.utils.text_dataset_from_directory(\n", - " 'aclImdb/train', \n", - " batch_size=batch_size, \n", - " validation_split=0.2, \n", - " subset='training', \n", + " 'aclImdb/train',\n", + " batch_size=batch_size,\n", + " validation_split=0.2,\n", + " subset='training',\n", " seed=seed)" ] }, @@ -322,7 +322,7 @@ "id": "JWq1SUIrp1a-" }, "source": [ - "Notice the reviews contain raw text (with punctuation and occasional HTML tags like `
`). You will show how to handle these in the following section. \n", + "Notice the reviews contain raw text (with punctuation and occasional HTML tags like `
`). You will show how to handle these in the following section.\n", "\n", "The labels are 0 or 1. To see which of these correspond to positive and negative movie reviews, you can check the `class_names` property on the dataset.\n" ] @@ -366,10 +366,10 @@ "outputs": [], "source": [ "raw_val_ds = tf.keras.utils.text_dataset_from_directory(\n", - " 'aclImdb/train', \n", - " batch_size=batch_size, \n", - " validation_split=0.2, \n", - " subset='validation', \n", + " 'aclImdb/train',\n", + " batch_size=batch_size,\n", + " validation_split=0.2,\n", + " subset='validation',\n", " seed=seed)" ] }, @@ -382,7 +382,7 @@ "outputs": [], "source": [ "raw_test_ds = tf.keras.utils.text_dataset_from_directory(\n", - " 'aclImdb/test', \n", + " 'aclImdb/test',\n", " batch_size=batch_size)" ] }, @@ -394,7 +394,7 @@ "source": [ "### Prepare the dataset for training\n", "\n", - "Next, you will standardize, tokenize, and vectorize the data using the helpful `tf.keras.layers.TextVectorization` layer. \n", + "Next, you will standardize, tokenize, and vectorize the data using the helpful `tf.keras.layers.TextVectorization` layer.\n", "\n", "Standardization refers to preprocessing the text, typically to remove punctuation or HTML elements to simplify the dataset. Tokenization refers to splitting strings into tokens (for example, splitting a sentence into individual words, by splitting on whitespace). Vectorization refers to converting tokens into numbers so they can be fed into a neural network. All of these tasks can be accomplished with this layer.\n", "\n", @@ -580,7 +580,7 @@ "\n", "`.cache()` keeps data in memory after it's loaded off disk. This will ensure the dataset does not become a bottleneck while training your model. If your dataset is too large to fit into memory, you can also use this method to create a performant on-disk cache, which is more efficient to read than many small files.\n", "\n", - "`.prefetch()` overlaps data preprocessing and model execution while training. \n", + "`.prefetch()` overlaps data preprocessing and model execution while training.\n", "\n", "You can learn more about both methods, as well as how to cache data to disk in the [data performance guide](https://www.tensorflow.org/guide/data_performance)." ] @@ -635,7 +635,7 @@ " layers.Dropout(0.2),\n", " layers.GlobalAveragePooling1D(),\n", " layers.Dropout(0.2),\n", - " layers.Dense(1)])\n", + " layers.Dense(1, activation='sigmoid')])\n", "\n", "model.summary()" ] @@ -674,9 +674,9 @@ }, "outputs": [], "source": [ - "model.compile(loss=losses.BinaryCrossentropy(from_logits=True),\n", + "model.compile(loss=losses.BinaryCrossentropy(),\n", " optimizer='adam',\n", - " metrics=tf.metrics.BinaryAccuracy(threshold=0.0))" + " metrics=[tf.metrics.BinaryAccuracy(threshold=0.5)])" ] }, { @@ -884,11 +884,11 @@ }, "outputs": [], "source": [ - "examples = [\n", + "examples = tf.constant([\n", " \"The movie was great!\",\n", " \"The movie was okay.\",\n", " \"The movie was terrible...\"\n", - "]\n", + "])\n", "\n", "export_model.predict(examples)" ] @@ -916,7 +916,7 @@ "\n", "This tutorial showed how to train a binary classifier from scratch on the IMDB dataset. As an exercise, you can modify this notebook to train a multi-class classifier to predict the tag of a programming question on [Stack Overflow](http://stackoverflow.com/).\n", "\n", - "A [dataset](https://storage.googleapis.com/download.tensorflow.org/data/stack_overflow_16k.tar.gz) has been prepared for you to use containing the body of several thousand programming questions (for example, \"How can I sort a dictionary by value in Python?\") posted to Stack Overflow. Each of these is labeled with exactly one tag (either Python, CSharp, JavaScript, or Java). Your task is to take a question as input, and predict the appropriate tag, in this case, Python. \n", + "A [dataset](https://storage.googleapis.com/download.tensorflow.org/data/stack_overflow_16k.tar.gz) has been prepared for you to use containing the body of several thousand programming questions (for example, \"How can I sort a dictionary by value in Python?\") posted to Stack Overflow. Each of these is labeled with exactly one tag (either Python, CSharp, JavaScript, or Java). Your task is to take a question as input, and predict the appropriate tag, in this case, Python.\n", "\n", "The dataset you will work with contains several thousand questions extracted from the much larger public Stack Overflow dataset on [BigQuery](https://console.cloud.google.com/marketplace/details/stack-exchange/stack-overflow), which contains more than 17 million posts.\n", "\n", @@ -950,7 +950,7 @@ "\n", "1. When plotting accuracy over time, change `binary_accuracy` and `val_binary_accuracy` to `accuracy` and `val_accuracy`, respectively.\n", "\n", - "1. Once these changes are complete, you will be able to train a multi-class classifier. " + "1. Once these changes are complete, you will be able to train a multi-class classifier." ] }, { @@ -968,8 +968,8 @@ "metadata": { "accelerator": "GPU", "colab": { - "collapsed_sections": [], "name": "text_classification.ipynb", + "provenance": [], "toc_visible": true }, "kernelspec": { diff --git a/site/en/tutorials/quickstart/advanced.ipynb b/site/en/tutorials/quickstart/advanced.ipynb index 2fe0ce85773..7cc134b2613 100644 --- a/site/en/tutorials/quickstart/advanced.ipynb +++ b/site/en/tutorials/quickstart/advanced.ipynb @@ -200,7 +200,7 @@ "id": "uGih-c2LgbJu" }, "source": [ - "Choose an optimizer and loss function for training: " + "Choose an optimizer and loss function for training:" ] }, { @@ -311,10 +311,10 @@ "\n", "for epoch in range(EPOCHS):\n", " # Reset the metrics at the start of the next epoch\n", - " train_loss.reset_states()\n", - " train_accuracy.reset_states()\n", - " test_loss.reset_states()\n", - " test_accuracy.reset_states()\n", + " train_loss.reset_state()\n", + " train_accuracy.reset_state()\n", + " test_loss.reset_state()\n", + " test_accuracy.reset_state()\n", "\n", " for images, labels in train_ds:\n", " train_step(images, labels)\n", @@ -324,10 +324,10 @@ "\n", " print(\n", " f'Epoch {epoch + 1}, '\n", - " f'Loss: {train_loss.result()}, '\n", - " f'Accuracy: {train_accuracy.result() * 100}, '\n", - " f'Test Loss: {test_loss.result()}, '\n", - " f'Test Accuracy: {test_accuracy.result() * 100}'\n", + " f'Loss: {train_loss.result():0.2f}, '\n", + " f'Accuracy: {train_accuracy.result() * 100:0.2f}, '\n", + " f'Test Loss: {test_loss.result():0.2f}, '\n", + " f'Test Accuracy: {test_accuracy.result() * 100:0.2f}'\n", " )" ] }, @@ -344,8 +344,8 @@ "metadata": { "accelerator": "GPU", "colab": { - "collapsed_sections": [], "name": "advanced.ipynb", + "provenance": [], "toc_visible": true }, "kernelspec": { diff --git a/site/en/tutorials/structured_data/time_series.ipynb b/site/en/tutorials/structured_data/time_series.ipynb index 0b0eb55bce3..31aab384859 100644 --- a/site/en/tutorials/structured_data/time_series.ipynb +++ b/site/en/tutorials/structured_data/time_series.ipynb @@ -70,7 +70,7 @@ "source": [ "This tutorial is an introduction to time series forecasting using TensorFlow. It builds a few different styles of models including Convolutional and Recurrent Neural Networks (CNNs and RNNs).\n", "\n", - "This is covered in two main parts, with subsections: \n", + "This is covered in two main parts, with subsections:\n", "\n", "* Forecast for a single time step:\n", " * A single feature.\n", @@ -452,7 +452,7 @@ "id": "HiurzTGQgf_D" }, "source": [ - "This gives the model access to the most important frequency features. In this case you knew ahead of time which frequencies were important. \n", + "This gives the model access to the most important frequency features. In this case you knew ahead of time which frequencies were important.\n", "\n", "If you don't have that information, you can determine which frequencies are important by extracting features with Fast Fourier Transform. To check the assumptions, here is the `tf.signal.rfft` of the temperature over time. Note the obvious peaks at frequencies near `1/year` and `1/day`:\n" ] @@ -590,13 +590,13 @@ "source": [ "## Data windowing\n", "\n", - "The models in this tutorial will make a set of predictions based on a window of consecutive samples from the data. \n", + "The models in this tutorial will make a set of predictions based on a window of consecutive samples from the data.\n", "\n", "The main features of the input windows are:\n", "\n", "- The width (number of time steps) of the input and label windows.\n", "- The time offset between them.\n", - "- Which features are used as inputs, labels, or both. \n", + "- Which features are used as inputs, labels, or both.\n", "\n", "This tutorial builds a variety of models (including Linear, DNN, CNN and RNN models), and uses them for both:\n", "\n", @@ -616,11 +616,11 @@ "\n", "1. For example, to make a single prediction 24 hours into the future, given 24 hours of history, you might define a window like this:\n", "\n", - " ![One prediction 24 hours into the future.](images/raw_window_24h.png)\n", + " ![One prediction 24 hours into the future.](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/raw_window_24h.png?raw=1)\n", "\n", "2. A model that makes a prediction one hour into the future, given six hours of history, would need a window like this:\n", "\n", - " ![One prediction one hour into the future.](images/raw_window_1h.png)" + " ![One prediction one hour into the future.](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/raw_window_1h.png?raw=1)" ] }, { @@ -744,7 +744,7 @@ "\n", "The example `w2` you define earlier will be split like this:\n", "\n", - "![The initial window is all consecutive samples, this splits it into an (inputs, labels) pairs](images/split_window.png)\n", + "![The initial window is all consecutive samples, this splits it into an (inputs, labels) pairs](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/split_window.png?raw=1)\n", "\n", "This diagram doesn't show the `features` axis of the data, but this `split_window` function also handles the `label_columns` so it can be used for both the single output and multi-output examples." ] @@ -1069,7 +1069,7 @@ "\n", "So, start by building models to predict the `T (degC)` value one hour into the future.\n", "\n", - "![Predict the next time step](images/narrow_window.png)\n", + "![Predict the next time step](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/narrow_window.png?raw=1)\n", "\n", "Configure a `WindowGenerator` object to produce these single-step `(input, label)` pairs:" ] @@ -1120,11 +1120,11 @@ "\n", "Before building a trainable model it would be good to have a performance baseline as a point for comparison with the later more complicated models.\n", "\n", - "This first task is to predict temperature one hour into the future, given the current value of all features. The current values include the current temperature. \n", + "This first task is to predict temperature one hour into the future, given the current value of all features. The current values include the current temperature.\n", "\n", "So, start with a model that just returns the current temperature as the prediction, predicting \"No change\". This is a reasonable baseline since temperature changes slowly. Of course, this baseline will work less well if you make a prediction further in the future.\n", "\n", - "![Send the input to the output](images/baseline.png)" + "![Send the input to the output](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/baseline.png?raw=1)" ] }, { @@ -1171,8 +1171,8 @@ "\n", "val_performance = {}\n", "performance = {}\n", - "val_performance['Baseline'] = baseline.evaluate(single_step_window.val)\n", - "performance['Baseline'] = baseline.evaluate(single_step_window.test, verbose=0)" + "val_performance['Baseline'] = baseline.evaluate(single_step_window.val, return_dict=True)\n", + "performance['Baseline'] = baseline.evaluate(single_step_window.test, verbose=0, return_dict=True)" ] }, { @@ -1211,7 +1211,7 @@ "source": [ "This expanded window can be passed directly to the same `baseline` model without any code changes. This is possible because the inputs and labels have the same number of time steps, and the baseline just forwards the input to the output:\n", "\n", - "![One prediction 1h into the future, ever hour.](images/last_window.png)" + "![One prediction 1h into the future, ever hour.](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/last_window.png?raw=1)" ] }, { @@ -1269,7 +1269,7 @@ "\n", "The simplest **trainable** model you can apply to this task is to insert linear transformation between the input and output. In this case the output from a time step only depends on that step:\n", "\n", - "![A single step prediction](images/narrow_window.png)\n", + "![A single step prediction](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/narrow_window.png?raw=1)\n", "\n", "A `tf.keras.layers.Dense` layer with no `activation` set is a linear model. The layer only transforms the last axis of the data from `(batch, time, inputs)` to `(batch, time, units)`; it is applied independently to every item across the `batch` and `time` axes." ] @@ -1352,8 +1352,8 @@ "source": [ "history = compile_and_fit(linear, single_step_window)\n", "\n", - "val_performance['Linear'] = linear.evaluate(single_step_window.val)\n", - "performance['Linear'] = linear.evaluate(single_step_window.test, verbose=0)" + "val_performance['Linear'] = linear.evaluate(single_step_window.val, return_dict=True)\n", + "performance['Linear'] = linear.evaluate(single_step_window.test, verbose=0, return_dict=True)" ] }, { @@ -1364,7 +1364,7 @@ "source": [ "Like the `baseline` model, the linear model can be called on batches of wide windows. Used this way the model makes a set of independent predictions on consecutive time steps. The `time` axis acts like another `batch` axis. There are no interactions between the predictions at each time step.\n", "\n", - "![A single step prediction](images/wide_window.png)" + "![A single step prediction](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/wide_window.png?raw=1)" ] }, { @@ -1430,7 +1430,7 @@ "id": "Ylng7215boIY" }, "source": [ - "Sometimes the model doesn't even place the most weight on the input `T (degC)`. This is one of the risks of random initialization. " + "Sometimes the model doesn't even place the most weight on the input `T (degC)`. This is one of the risks of random initialization." ] }, { @@ -1443,7 +1443,7 @@ "\n", "Before applying models that actually operate on multiple time-steps, it's worth checking the performance of deeper, more powerful, single input step models.\n", "\n", - "Here's a model similar to the `linear` model, except it stacks several a few `Dense` layers between the input and the output: " + "Here's a model similar to the `linear` model, except it stacks several a few `Dense` layers between the input and the output:" ] }, { @@ -1462,8 +1462,8 @@ "\n", "history = compile_and_fit(dense, single_step_window)\n", "\n", - "val_performance['Dense'] = dense.evaluate(single_step_window.val)\n", - "performance['Dense'] = dense.evaluate(single_step_window.test, verbose=0)" + "val_performance['Dense'] = dense.evaluate(single_step_window.val, return_dict=True)\n", + "performance['Dense'] = dense.evaluate(single_step_window.test, verbose=0, return_dict=True)" ] }, { @@ -1476,7 +1476,7 @@ "\n", "A single-time-step model has no context for the current values of its inputs. It can't see how the input features are changing over time. To address this issue the model needs access to multiple time steps when making predictions:\n", "\n", - "![Three time steps are used for each prediction.](images/conv_window.png)\n" + "![Three time steps are used for each prediction.](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/conv_window.png?raw=1)\n" ] }, { @@ -1526,7 +1526,7 @@ "outputs": [], "source": [ "conv_window.plot()\n", - "plt.title(\"Given 3 hours of inputs, predict 1 hour into the future.\")" + "plt.suptitle(\"Given 3 hours of inputs, predict 1 hour into the future.\")" ] }, { @@ -1581,8 +1581,8 @@ "history = compile_and_fit(multi_step_dense, conv_window)\n", "\n", "IPython.display.clear_output()\n", - "val_performance['Multi step dense'] = multi_step_dense.evaluate(conv_window.val)\n", - "performance['Multi step dense'] = multi_step_dense.evaluate(conv_window.test, verbose=0)" + "val_performance['Multi step dense'] = multi_step_dense.evaluate(conv_window.val, return_dict=True)\n", + "performance['Multi step dense'] = multi_step_dense.evaluate(conv_window.test, verbose=0, return_dict=True)" ] }, { @@ -1602,7 +1602,7 @@ "id": "gWfrsP8mq8lV" }, "source": [ - "The main down-side of this approach is that the resulting model can only be executed on input windows of exactly this shape. " + "The main down-side of this approach is that the resulting model can only be executed on input windows of exactly this shape." ] }, { @@ -1636,7 +1636,7 @@ }, "source": [ "### Convolution neural network\n", - " \n", + "\n", "A convolution layer (`tf.keras.layers.Conv1D`) also takes multiple time steps as input to each prediction." ] }, @@ -1646,7 +1646,7 @@ "id": "cdLBwoaHmsWb" }, "source": [ - "Below is the **same** model as `multi_step_dense`, re-written with a convolution. \n", + "Below is the **same** model as `multi_step_dense`, re-written with a convolution.\n", "\n", "Note the changes:\n", "* The `tf.keras.layers.Flatten` and the first `tf.keras.layers.Dense` are replaced by a `tf.keras.layers.Conv1D`.\n", @@ -1712,8 +1712,8 @@ "history = compile_and_fit(conv_model, conv_window)\n", "\n", "IPython.display.clear_output()\n", - "val_performance['Conv'] = conv_model.evaluate(conv_window.val)\n", - "performance['Conv'] = conv_model.evaluate(conv_window.test, verbose=0)" + "val_performance['Conv'] = conv_model.evaluate(conv_window.val, return_dict=True)\n", + "performance['Conv'] = conv_model.evaluate(conv_window.test, verbose=0, return_dict=True)" ] }, { @@ -1724,7 +1724,7 @@ "source": [ "The difference between this `conv_model` and the `multi_step_dense` model is that the `conv_model` can be run on inputs of any length. The convolutional layer is applied to a sliding window of inputs:\n", "\n", - "![Executing a convolutional model on a sequence](images/wide_conv_window.png)\n", + "![Executing a convolutional model on a sequence](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/wide_conv_window.png?raw=1)\n", "\n", "If you run it on wider input, it produces wider output:" ] @@ -1749,7 +1749,7 @@ "id": "h_WGxtLIHhRF" }, "source": [ - "Note that the output is shorter than the input. To make training or plotting work, you need the labels, and prediction to have the same length. So build a `WindowGenerator` to produce wide windows with a few extra input time steps so the label and prediction lengths match: " + "Note that the output is shorter than the input. To make training or plotting work, you need the labels, and prediction to have the same length. So build a `WindowGenerator` to produce wide windows with a few extra input time steps so the label and prediction lengths match:" ] }, { @@ -1828,15 +1828,15 @@ "source": [ "An important constructor argument for all Keras RNN layers, such as `tf.keras.layers.LSTM`, is the `return_sequences` argument. This setting can configure the layer in one of two ways:\n", "\n", - "1. If `False`, the default, the layer only returns the output of the final time step, giving the model time to warm up its internal state before making a single prediction: \n", + "1. If `False`, the default, the layer only returns the output of the final time step, giving the model time to warm up its internal state before making a single prediction:\n", "\n", - "![An LSTM warming up and making a single prediction](images/lstm_1_window.png)\n", + "![An LSTM warming up and making a single prediction](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/lstm_1_window.png?raw=1)\n", "\n", "2. If `True`, the layer returns an output for each input. This is useful for:\n", - " * Stacking RNN layers. \n", + " * Stacking RNN layers.\n", " * Training a model on multiple time steps simultaneously.\n", "\n", - "![An LSTM making a prediction after every time step](images/lstm_many_window.png)" + "![An LSTM making a prediction after every time step](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/lstm_many_window.png?raw=1)" ] }, { @@ -1889,8 +1889,8 @@ "history = compile_and_fit(lstm_model, wide_window)\n", "\n", "IPython.display.clear_output()\n", - "val_performance['LSTM'] = lstm_model.evaluate(wide_window.val)\n", - "performance['LSTM'] = lstm_model.evaluate(wide_window.test, verbose=0)" + "val_performance['LSTM'] = lstm_model.evaluate(wide_window.val, return_dict=True)\n", + "performance['LSTM'] = lstm_model.evaluate(wide_window.test, verbose=0, return_dict=True)" ] }, { @@ -1922,6 +1922,29 @@ "With this dataset typically each of the models does slightly better than the one before it:" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "dMPev9Nzd4mD" + }, + "outputs": [], + "source": [ + "cm = lstm_model.metrics[1]\n", + "cm.metrics" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "6is3g113eIIa" + }, + "outputs": [], + "source": [ + "val_performance" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1933,9 +1956,8 @@ "x = np.arange(len(performance))\n", "width = 0.3\n", "metric_name = 'mean_absolute_error'\n", - "metric_index = lstm_model.metrics_names.index('mean_absolute_error')\n", - "val_mae = [v[metric_index] for v in val_performance.values()]\n", - "test_mae = [v[metric_index] for v in performance.values()]\n", + "val_mae = [v[metric_name] for v in val_performance.values()]\n", + "test_mae = [v[metric_name] for v in performance.values()]\n", "\n", "plt.ylabel('mean_absolute_error [T (degC), normalized]')\n", "plt.bar(x - 0.17, val_mae, width, label='Validation')\n", @@ -1954,7 +1976,7 @@ "outputs": [], "source": [ "for name, value in performance.items():\n", - " print(f'{name:12s}: {value[1]:0.4f}')" + " print(f'{name:12s}: {value[metric_name]:0.4f}')" ] }, { @@ -1979,7 +2001,7 @@ "outputs": [], "source": [ "single_step_window = WindowGenerator(\n", - " # `WindowGenerator` returns all features as labels if you \n", + " # `WindowGenerator` returns all features as labels if you\n", " # don't set the `label_columns` argument.\n", " input_width=1, label_width=1, shift=1)\n", "\n", @@ -2034,8 +2056,8 @@ "source": [ "val_performance = {}\n", "performance = {}\n", - "val_performance['Baseline'] = baseline.evaluate(wide_window.val)\n", - "performance['Baseline'] = baseline.evaluate(wide_window.test, verbose=0)" + "val_performance['Baseline'] = baseline.evaluate(wide_window.val, return_dict=True)\n", + "performance['Baseline'] = baseline.evaluate(wide_window.test, verbose=0, return_dict=True)" ] }, { @@ -2073,8 +2095,8 @@ "history = compile_and_fit(dense, single_step_window)\n", "\n", "IPython.display.clear_output()\n", - "val_performance['Dense'] = dense.evaluate(single_step_window.val)\n", - "performance['Dense'] = dense.evaluate(single_step_window.test, verbose=0)" + "val_performance['Dense'] = dense.evaluate(single_step_window.val, return_dict=True)\n", + "performance['Dense'] = dense.evaluate(single_step_window.test, verbose=0, return_dict=True)" ] }, { @@ -2108,8 +2130,8 @@ "history = compile_and_fit(lstm_model, wide_window)\n", "\n", "IPython.display.clear_output()\n", - "val_performance['LSTM'] = lstm_model.evaluate( wide_window.val)\n", - "performance['LSTM'] = lstm_model.evaluate( wide_window.test, verbose=0)\n", + "val_performance['LSTM'] = lstm_model.evaluate( wide_window.val, return_dict=True)\n", + "performance['LSTM'] = lstm_model.evaluate( wide_window.test, verbose=0, return_dict=True)\n", "\n", "print()" ] @@ -2132,7 +2154,7 @@ "\n", "That is how you take advantage of the knowledge that the change should be small.\n", "\n", - "![A model with a residual connection](images/residual.png)\n", + "![A model with a residual connection](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/residual.png?raw=1)\n", "\n", "Essentially, this initializes the model to match the `Baseline`. For this task it helps models converge faster, with slightly better performance." ] @@ -2143,7 +2165,7 @@ "id": "yP58A_ORx0kM" }, "source": [ - "This approach can be used in conjunction with any model discussed in this tutorial. \n", + "This approach can be used in conjunction with any model discussed in this tutorial.\n", "\n", "Here, it is being applied to the LSTM model, note the use of the `tf.initializers.zeros` to ensure that the initial predicted changes are small, and don't overpower the residual connection. There are no symmetry-breaking concerns for the gradients here, since the `zeros` are only used on the last layer." ] @@ -2192,8 +2214,8 @@ "history = compile_and_fit(residual_lstm, wide_window)\n", "\n", "IPython.display.clear_output()\n", - "val_performance['Residual LSTM'] = residual_lstm.evaluate(wide_window.val)\n", - "performance['Residual LSTM'] = residual_lstm.evaluate(wide_window.test, verbose=0)\n", + "val_performance['Residual LSTM'] = residual_lstm.evaluate(wide_window.val, return_dict=True)\n", + "performance['Residual LSTM'] = residual_lstm.evaluate(wide_window.test, verbose=0, return_dict=True)\n", "print()" ] }, @@ -2227,9 +2249,8 @@ "width = 0.3\n", "\n", "metric_name = 'mean_absolute_error'\n", - "metric_index = lstm_model.metrics_names.index('mean_absolute_error')\n", - "val_mae = [v[metric_index] for v in val_performance.values()]\n", - "test_mae = [v[metric_index] for v in performance.values()]\n", + "val_mae = [v[metric_name] for v in val_performance.values()]\n", + "test_mae = [v[metric_name] for v in performance.values()]\n", "\n", "plt.bar(x - 0.17, val_mae, width, label='Validation')\n", "plt.bar(x + 0.17, test_mae, width, label='Test')\n", @@ -2248,7 +2269,7 @@ "outputs": [], "source": [ "for name, value in performance.items():\n", - " print(f'{name:15s}: {value[1]:0.4f}')" + " print(f'{name:15s}: {value[metric_name]:0.4f}')" ] }, { @@ -2327,7 +2348,7 @@ "source": [ "A simple baseline for this task is to repeat the last input time step for the required number of output time steps:\n", "\n", - "![Repeat the last input, for each output step](images/multistep_last.png)" + "![Repeat the last input, for each output step](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/multistep_last.png?raw=1)" ] }, { @@ -2349,8 +2370,8 @@ "multi_val_performance = {}\n", "multi_performance = {}\n", "\n", - "multi_val_performance['Last'] = last_baseline.evaluate(multi_window.val)\n", - "multi_performance['Last'] = last_baseline.evaluate(multi_window.test, verbose=0)\n", + "multi_val_performance['Last'] = last_baseline.evaluate(multi_window.val, return_dict=True)\n", + "multi_performance['Last'] = last_baseline.evaluate(multi_window.test, verbose=0, return_dict=True)\n", "multi_window.plot(last_baseline)" ] }, @@ -2362,7 +2383,7 @@ "source": [ "Since this task is to predict 24 hours into the future, given 24 hours of the past, another simple approach is to repeat the previous day, assuming tomorrow will be similar:\n", "\n", - "![Repeat the previous day](images/multistep_repeat.png)" + "![Repeat the previous day](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/multistep_repeat.png?raw=1)" ] }, { @@ -2381,8 +2402,8 @@ "repeat_baseline.compile(loss=tf.keras.losses.MeanSquaredError(),\n", " metrics=[tf.keras.metrics.MeanAbsoluteError()])\n", "\n", - "multi_val_performance['Repeat'] = repeat_baseline.evaluate(multi_window.val)\n", - "multi_performance['Repeat'] = repeat_baseline.evaluate(multi_window.test, verbose=0)\n", + "multi_val_performance['Repeat'] = repeat_baseline.evaluate(multi_window.val, return_dict=True)\n", + "multi_performance['Repeat'] = repeat_baseline.evaluate(multi_window.test, verbose=0, return_dict=True)\n", "multi_window.plot(repeat_baseline)" ] }, @@ -2409,7 +2430,7 @@ "\n", "A simple linear model based on the last input time step does better than either baseline, but is underpowered. The model needs to predict `OUTPUT_STEPS` time steps, from a single input time step with a linear projection. It can only capture a low-dimensional slice of the behavior, likely based mainly on the time of day and time of year.\n", "\n", - "![Predict all timesteps from the last time-step](images/multistep_dense.png)" + "![Predict all timesteps from the last time-step](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/multistep_dense.png?raw=1)" ] }, { @@ -2434,8 +2455,8 @@ "history = compile_and_fit(multi_linear_model, multi_window)\n", "\n", "IPython.display.clear_output()\n", - "multi_val_performance['Linear'] = multi_linear_model.evaluate(multi_window.val)\n", - "multi_performance['Linear'] = multi_linear_model.evaluate(multi_window.test, verbose=0)\n", + "multi_val_performance['Linear'] = multi_linear_model.evaluate(multi_window.val, return_dict=True)\n", + "multi_performance['Linear'] = multi_linear_model.evaluate(multi_window.test, verbose=0, return_dict=True)\n", "multi_window.plot(multi_linear_model)" ] }, @@ -2474,8 +2495,8 @@ "history = compile_and_fit(multi_dense_model, multi_window)\n", "\n", "IPython.display.clear_output()\n", - "multi_val_performance['Dense'] = multi_dense_model.evaluate(multi_window.val)\n", - "multi_performance['Dense'] = multi_dense_model.evaluate(multi_window.test, verbose=0)\n", + "multi_val_performance['Dense'] = multi_dense_model.evaluate(multi_window.val, return_dict=True)\n", + "multi_performance['Dense'] = multi_dense_model.evaluate(multi_window.test, verbose=0, return_dict=True)\n", "multi_window.plot(multi_dense_model)" ] }, @@ -2496,7 +2517,7 @@ "source": [ "A convolutional model makes predictions based on a fixed-width history, which may lead to better performance than the dense model since it can see how things are changing over time:\n", "\n", - "![A convolutional model sees how things change over time](images/multistep_conv.png)" + "![A convolutional model sees how things change over time](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/multistep_conv.png?raw=1)" ] }, { @@ -2524,8 +2545,8 @@ "\n", "IPython.display.clear_output()\n", "\n", - "multi_val_performance['Conv'] = multi_conv_model.evaluate(multi_window.val)\n", - "multi_performance['Conv'] = multi_conv_model.evaluate(multi_window.test, verbose=0)\n", + "multi_val_performance['Conv'] = multi_conv_model.evaluate(multi_window.val, return_dict=True)\n", + "multi_performance['Conv'] = multi_conv_model.evaluate(multi_window.test, verbose=0, return_dict=True)\n", "multi_window.plot(multi_conv_model)" ] }, @@ -2548,7 +2569,7 @@ "\n", "In this single-shot format, the LSTM only needs to produce an output at the last time step, so set `return_sequences=False` in `tf.keras.layers.LSTM`.\n", "\n", - "![The LSTM accumulates state over the input window, and makes a single prediction for the next 24 hours](images/multistep_lstm.png)\n" + "![The LSTM accumulates state over the input window, and makes a single prediction for the next 24 hours](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/multistep_lstm.png?raw=1)\n" ] }, { @@ -2574,8 +2595,8 @@ "\n", "IPython.display.clear_output()\n", "\n", - "multi_val_performance['LSTM'] = multi_lstm_model.evaluate(multi_window.val)\n", - "multi_performance['LSTM'] = multi_lstm_model.evaluate(multi_window.test, verbose=0)\n", + "multi_val_performance['LSTM'] = multi_lstm_model.evaluate(multi_window.val, return_dict=True)\n", + "multi_performance['LSTM'] = multi_lstm_model.evaluate(multi_window.test, verbose=0, return_dict=True)\n", "multi_window.plot(multi_lstm_model)" ] }, @@ -2595,7 +2616,7 @@ "\n", "You could take any of the single-step multi-output models trained in the first half of this tutorial and run in an autoregressive feedback loop, but here you'll focus on building a model that's been explicitly trained to do that.\n", "\n", - "![Feedback a model's output to its input](images/multistep_autoregressive.png)" + "![Feedback a model's output to its input](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/structured_data/images/multistep_autoregressive.png?raw=1)" ] }, { @@ -2794,8 +2815,8 @@ "\n", "IPython.display.clear_output()\n", "\n", - "multi_val_performance['AR LSTM'] = feedback_model.evaluate(multi_window.val)\n", - "multi_performance['AR LSTM'] = feedback_model.evaluate(multi_window.test, verbose=0)\n", + "multi_val_performance['AR LSTM'] = feedback_model.evaluate(multi_window.val, return_dict=True)\n", + "multi_performance['AR LSTM'] = feedback_model.evaluate(multi_window.test, verbose=0, return_dict=True)\n", "multi_window.plot(feedback_model)" ] }, @@ -2829,9 +2850,8 @@ "width = 0.3\n", "\n", "metric_name = 'mean_absolute_error'\n", - "metric_index = lstm_model.metrics_names.index('mean_absolute_error')\n", - "val_mae = [v[metric_index] for v in multi_val_performance.values()]\n", - "test_mae = [v[metric_index] for v in multi_performance.values()]\n", + "val_mae = [v[metric_name] for v in multi_val_performance.values()]\n", + "test_mae = [v[metric_name] for v in multi_performance.values()]\n", "\n", "plt.bar(x - 0.17, val_mae, width, label='Validation')\n", "plt.bar(x + 0.17, test_mae, width, label='Test')\n", @@ -2847,7 +2867,7 @@ "id": "Zq3hUsedCEmJ" }, "source": [ - "The metrics for the multi-output models in the first half of this tutorial show the performance averaged across all output features. These performances are similar but also averaged across output time steps. " + "The metrics for the multi-output models in the first half of this tutorial show the performance averaged across all output features. These performances are similar but also averaged across output time steps." ] }, { @@ -2859,7 +2879,7 @@ "outputs": [], "source": [ "for name, value in multi_performance.items():\n", - " print(f'{name:8s}: {value[1]:0.4f}')" + " print(f'{name:8s}: {value[metric_name]:0.4f}')" ] }, { @@ -2894,8 +2914,8 @@ "metadata": { "accelerator": "GPU", "colab": { - "collapsed_sections": [], "name": "time_series.ipynb", + "provenance": [], "toc_visible": true }, "kernelspec": { From ff989f0d94cd81cce45a8db0f540e605ce05512b Mon Sep 17 00:00:00 2001 From: Jongbin Park Date: Tue, 26 Mar 2024 18:00:55 -0700 Subject: [PATCH 10/10] Fix signature generation when the method is dataclass instance. PiperOrigin-RevId: 619368090 --- tools/tensorflow_docs/api_generator/signature.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tensorflow_docs/api_generator/signature.py b/tools/tensorflow_docs/api_generator/signature.py index 7ef8f1f856d..dacf5d2bada 100644 --- a/tools/tensorflow_docs/api_generator/signature.py +++ b/tools/tensorflow_docs/api_generator/signature.py @@ -580,7 +580,7 @@ def generate_signature( sig = sig.replace(parameters=params) - if dataclasses.is_dataclass(func): + if dataclasses.is_dataclass(func) and inspect.isclass(func): sig = sig.replace(return_annotation=EMPTY) extract_fn = _extract_class_defaults_and_annotations else:
VersionPython versionCompilerBuild toolscuDNNCUDA
tensorflow-2.16.13.9-3.12Clang 17.0.1Bazel 6.5.08.912.3
tensorflow-2.16.13.9-3.12Clang 17.0.6Bazel 6.5.08.912.3
tensorflow-2.15.03.9-3.11Clang 16.0.0Bazel 6.1.08.912.2
tensorflow-2.14.03.9-3.11Clang 16.0.0Bazel 6.1.08.711.8
tensorflow-2.13.03.8-3.11Clang 16.0.0Bazel 5.3.08.611.8