Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/guide/bert_preprocessing_guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"cell_type": "code",
"execution_count": null,
"source": [
"!pip install -q -U \"tensorflow-text==2.11.*\""
"!pip install -q -U tensorflow-text"
],
"outputs": [],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/subwords_tokenizer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
},
"outputs": [],
"source": [
"!pip install -q -U \"tensorflow-text==2.11.*\""
"!pip install -q -U tensorflow-text"
]
},
{
Expand Down
5 changes: 4 additions & 1 deletion docs/guide/text_tf_lite.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
},
"outputs": [],
"source": [
"!pip install -U \"tensorflow-text==2.11.*\""
"!pip install -q -U tensorflow-text tf-keras"
]
},
{
Expand All @@ -120,6 +120,9 @@
},
"outputs": [],
"source": [
"import os\n",
"os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"\n",
"\n",
"from absl import app\n",
"import numpy as np\n",
"import tensorflow as tf\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/tokenizers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
},
"outputs": [],
"source": [
"!pip install -q \"tensorflow-text==2.11.*\""
"!pip install -q -U tensorflow-text"
]
},
{
Expand Down
15 changes: 6 additions & 9 deletions docs/tutorials/bert_glue.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
},
"outputs": [],
"source": [
"!pip install -q -U \"tensorflow-text==2.11.*\""
"!pip install -q -U tensorflow-text"
]
},
{
Expand All @@ -136,7 +136,7 @@
},
"outputs": [],
"source": [
"!pip install -q -U tf-models-official==2.11.0"
"!pip install -q -U tf-models-official"
]
},
{
Expand All @@ -159,11 +159,12 @@
"outputs": [],
"source": [
"import os\n",
"os.environ['TF_USE_LEGACY_KERAS'] = '1'\n",
"\n",
"import tensorflow as tf\n",
"import tensorflow_hub as hub\n",
"import tensorflow_datasets as tfds\n",
"import tensorflow_text as text # A dependency of the preprocessing model\n",
"import tensorflow_addons as tfa\n",
"from official.nlp import optimization\n",
"import numpy as np\n",
"\n",
Expand Down Expand Up @@ -817,12 +818,8 @@
"def get_configuration(glue_task):\n",
"\n",
" loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)\n",
"\n",
" if glue_task == 'glue/cola':\n",
" metrics = tfa.metrics.MatthewsCorrelationCoefficient(num_classes=2)\n",
" else:\n",
" metrics = tf.keras.metrics.SparseCategoricalAccuracy(\n",
" 'accuracy', dtype=tf.float32)\n",
" metrics = tf.keras.metrics.SparseCategoricalAccuracy(\n",
" 'accuracy', dtype=tf.float32)\n",
"\n",
" return metrics, loss"
]
Expand Down
14 changes: 9 additions & 5 deletions docs/tutorials/classify_text_with_bert.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"outputs": [],
"source": [
"# A dependency of the preprocessing for BERT inputs\n",
"!pip install -U \"tensorflow-text==2.13.*\""
"!pip install -q -U tensorflow-text"
]
},
{
Expand All @@ -129,7 +129,7 @@
},
"outputs": [],
"source": [
"!pip install \"tf-models-official==2.13.*\""
"!pip install -q -U tf-models-official"
]
},
{
Expand All @@ -143,6 +143,8 @@
"import os\n",
"import shutil\n",
"\n",
"os.environ['TF_USE_LEGACY_KERAS'] = '1'\n",
"\n",
"import tensorflow as tf\n",
"import tensorflow_hub as hub\n",
"import tensorflow_text as text\n",
Expand Down Expand Up @@ -192,6 +194,8 @@
" cache_subdir='')\n",
"\n",
"dataset_dir = os.path.join(os.path.dirname(dataset), 'aclImdb')\n",
"if not os.path.exists(dataset_dir):\n",
" dataset_dir = os.path.join(dataset, 'aclImdb')\n",
"\n",
"train_dir = os.path.join(dataset_dir, 'train')\n",
"\n",
Expand Down Expand Up @@ -226,7 +230,7 @@
"seed = 42\n",
"\n",
"raw_train_ds = tf.keras.utils.text_dataset_from_directory(\n",
" 'aclImdb/train',\n",
" train_dir,\n",
" batch_size=batch_size,\n",
" validation_split=0.2,\n",
" subset='training',\n",
Expand All @@ -236,7 +240,7 @@
"train_ds = raw_train_ds.cache().prefetch(buffer_size=AUTOTUNE)\n",
"\n",
"val_ds = tf.keras.utils.text_dataset_from_directory(\n",
" 'aclImdb/train',\n",
" train_dir,\n",
" batch_size=batch_size,\n",
" validation_split=0.2,\n",
" subset='validation',\n",
Expand All @@ -245,7 +249,7 @@
"val_ds = val_ds.cache().prefetch(buffer_size=AUTOTUNE)\n",
"\n",
"test_ds = tf.keras.utils.text_dataset_from_directory(\n",
" 'aclImdb/test',\n",
" os.path.join(dataset_dir, 'test'),\n",
" batch_size=batch_size)\n",
"\n",
"test_ds = test_ds.cache().prefetch(buffer_size=AUTOTUNE)"
Expand Down
30 changes: 5 additions & 25 deletions docs/tutorials/image_captioning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,6 @@
"## Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "gc06pTaBbl72"
},
"outputs": [],
"source": [
"!apt install --allow-change-held-packages libcudnn8=8.6.0.163-1+cuda11.8"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "2R1hQGtZEi8Y"
},
"outputs": [],
"source": [
"!pip uninstall -y tensorflow estimator keras"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -176,7 +154,7 @@
},
"outputs": [],
"source": [
"!pip install -U tensorflow_text tensorflow tensorflow_datasets"
"!pip install -q -U tensorflow-text tensorflow_datasets tf-keras"
]
},
{
Expand All @@ -187,7 +165,7 @@
},
"outputs": [],
"source": [
"!pip install einops"
"!pip install -q einops"
]
},
{
Expand All @@ -209,14 +187,16 @@
"outputs": [],
"source": [
"#@title\n",
"import os\n",
"os.environ['TF_USE_LEGACY_KERAS'] = '1'\n",
"\n",
"import concurrent.futures\n",
"import collections\n",
"import dataclasses\n",
"import hashlib\n",
"import itertools\n",
"import json\n",
"import math\n",
"import os\n",
"import pathlib\n",
"import random\n",
"import re\n",
Expand Down
11 changes: 8 additions & 3 deletions docs/tutorials/nmt_with_attention.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@
},
"outputs": [],
"source": [
"!pip install \"tensorflow-text\u003e=2.11\"\n",
"!pip install einops"
"!pip install -q -U tensorflow-text tf-keras\n",
"!pip install -q einops"
]
},
{
Expand All @@ -142,6 +142,9 @@
},
"outputs": [],
"source": [
"import os\n",
"os.environ['TF_USE_LEGACY_KERAS'] = '1'\n",
"\n",
"import numpy as np\n",
"\n",
"import typing\n",
Expand Down Expand Up @@ -256,7 +259,9 @@
" 'spa-eng.zip', origin='http://storage.googleapis.com/download.tensorflow.org/data/spa-eng.zip',\n",
" extract=True)\n",
"\n",
"path_to_file = pathlib.Path(path_to_zip).parent/'spa-eng/spa.txt'"
"path_to_file = pathlib.Path(path_to_zip).parent/'spa-eng/spa.txt'\n",
"if not path_to_file.exists():\n",
" path_to_file = pathlib.Path(path_to_zip)/'spa-eng/spa.txt'"
]
},
{
Expand Down
5 changes: 5 additions & 0 deletions docs/tutorials/text_classification_rnn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
},
"outputs": [],
"source": [
"!pip install -q -U tf-keras\n",
"\n",
"import os\n",
"os.environ['TF_USE_LEGACY_KERAS'] = '1'\n",
"\n",
"import numpy as np\n",
"\n",
"import tensorflow_datasets as tfds\n",
Expand Down
12 changes: 8 additions & 4 deletions docs/tutorials/text_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,15 @@
},
"outputs": [],
"source": [
"import tensorflow as tf\n",
"!pip install -q -U tf-keras\n",
"\n",
"import numpy as np\n",
"import os\n",
"import time"
"import time\n",
"\n",
"os.environ['TF_USE_LEGACY_KERAS'] = '1'\n",
"\n",
"import numpy as np\n",
"import tensorflow as tf"
]
},
{
Expand Down Expand Up @@ -673,7 +677,7 @@
"source": [
"class MyModel(tf.keras.Model):\n",
" def __init__(self, vocab_size, embedding_dim, rnn_units):\n",
" super().__init__(self)\n",
" super().__init__()\n",
" self.embedding = tf.keras.layers.Embedding(vocab_size, embedding_dim)\n",
" self.gru = tf.keras.layers.GRU(rnn_units,\n",
" return_sequences=True,\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/text_similarity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
},
"outputs": [],
"source": [
"!pip install -q \"tensorflow-text==2.11.*\""
"!pip install -q -U tensorflow-text"
]
},
{
Expand Down
11 changes: 4 additions & 7 deletions docs/tutorials/transformer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,7 @@
},
"outputs": [],
"source": [
"# Install the most re version of TensorFlow to use the improved\n",
"# masking support for `tf.keras.layers.MultiHeadAttention`.\n",
"!apt install --allow-change-held-packages libcudnn8=8.1.0.77-1+cuda11.2\n",
"!pip uninstall -y -q tensorflow keras tensorflow-estimator tensorflow-text\n",
"!pip install protobuf~=3.20.3\n",
"!pip install -q tensorflow_datasets\n",
"!pip install -q -U tensorflow-text tensorflow"
"!pip install -q -U tensorflow-text tensorflow_datasets tf-keras"
]
},
{
Expand All @@ -248,8 +242,11 @@
"outputs": [],
"source": [
"import logging\n",
"import os\n",
"import time\n",
"\n",
"os.environ['TF_USE_LEGACY_KERAS'] = '1'\n",
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
Expand Down
18 changes: 5 additions & 13 deletions docs/tutorials/uncertainty_quantification_with_sngp_bert.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@
"## Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "l2dCK-rbYXsb"
},
"outputs": [],
"source": [
"!pip uninstall -y tensorflow tf-text"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -111,7 +100,7 @@
},
"outputs": [],
"source": [
"!pip install \"tensorflow-text==2.11.*\""
"!pip install -q -U tensorflow-text"
]
},
{
Expand All @@ -122,7 +111,7 @@
},
"outputs": [],
"source": [
"!pip install -U tf-models-official==2.11.0"
"!pip install -q -U tf-models-official"
]
},
{
Expand All @@ -133,6 +122,9 @@
},
"outputs": [],
"source": [
"import os\n",
"os.environ['TF_USE_LEGACY_KERAS'] = '1'\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import sklearn.metrics\n",
Expand Down
Loading
Loading