Skip to content

Commit aef8ca7

Browse files
abatterytensorflower-gardener
authored andcommitted
Fix keras importing failures at the colab.
PiperOrigin-RevId: 607162489
1 parent 590c8de commit aef8ca7

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

tensorflow_model_optimization/g3doc/guide/clustering/clustering_example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"outputs": [],
121121
"source": [
122122
"import tensorflow as tf\n",
123-
"import tf_keras as keras\n",
123+
"from tensorflow_model_optimization.python.core.keras.compat import keras\n",
124124
"\n",
125125
"import numpy as np\n",
126126
"import tempfile\n",

tensorflow_model_optimization/g3doc/guide/pruning/pruning_with_keras.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"import tensorflow as tf\n",
124124
"import numpy as np\n",
125125
"\n",
126-
"import tf_keras as keras\n",
126+
"from tensorflow_model_optimization.python.core.keras.compat import keras\n",
127127
"\n",
128128
"%load_ext tensorboard"
129129
]

tensorflow_model_optimization/g3doc/guide/quantization/training_example.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"\n",
126126
"import tensorflow as tf\n",
127127
"\n",
128-
"from tensorflow import keras"
128+
"from tensorflow_model_optimization.python.core.keras.compat import keras"
129129
]
130130
},
131131
{
@@ -146,7 +146,7 @@
146146
"outputs": [],
147147
"source": [
148148
"# Load MNIST dataset\n",
149-
"mnist = keras.datasets.mnist\n",
149+
"mnist = tf.keras.datasets.mnist\n",
150150
"(train_images, train_labels), (test_images, test_labels) = mnist.load_data()\n",
151151
"\n",
152152
"# Normalize the input image so that each pixel value is between 0 to 1.\n",
@@ -216,7 +216,6 @@
216216
"outputs": [],
217217
"source": [
218218
"import tensorflow_model_optimization as tfmot\n",
219-
"import tf_keras as keras\n",
220219
"\n",
221220
"quantize_model = tfmot.quantization.keras.quantize_model\n",
222221
"\n",

0 commit comments

Comments
 (0)