Skip to content

Commit edead04

Browse files
arjungtensorflow-copybara
authored andcommitted
Update graph-NSL tutorials to i) use the default TF version in colab, which is currently TF 2.2.0-rc4, and ii) replace a deprecated API when checking for GPU availability.
PiperOrigin-RevId: 310414689
1 parent 9950642 commit edead04

File tree

2 files changed

+9
-39
lines changed

2 files changed

+9
-39
lines changed

g3doc/tutorials/graph_keras_lstm_imdb.ipynb

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,8 @@
114114
"source": [
115115
"## Requirements\n",
116116
"\n",
117-
"1. Install TensorFlow 2.0.x to create an interactive development environment with eager execution.\n",
118-
"2. Install the Neural Structured Learning package.\n",
119-
"3. Install tensorflow-hub."
120-
]
121-
},
122-
{
123-
"cell_type": "code",
124-
"execution_count": 0,
125-
"metadata": {
126-
"colab": {},
127-
"colab_type": "code",
128-
"id": "yDUe7gk_ztZ-"
129-
},
130-
"outputs": [],
131-
"source": [
132-
"!pip install tensorflow-gpu==2.0.1"
117+
"1. Install the Neural Structured Learning package.\n",
118+
"2. Install tensorflow-hub."
133119
]
134120
},
135121
{
@@ -172,8 +158,6 @@
172158
"import neural_structured_learning as nsl\n",
173159
"\n",
174160
"import tensorflow as tf\n",
175-
"tf.compat.v1.enable_v2_behavior()\n",
176-
"\n",
177161
"import tensorflow_hub as hub\n",
178162
"\n",
179163
"# Resets notebook state\n",
@@ -182,7 +166,9 @@
182166
"print(\"Version: \", tf.__version__)\n",
183167
"print(\"Eager mode: \", tf.executing_eagerly())\n",
184168
"print(\"Hub version: \", hub.__version__)\n",
185-
"print(\"GPU is\", \"available\" if tf.test.is_gpu_available() else \"NOT AVAILABLE\")"
169+
"print(\n",
170+
" \"GPU is\",\n",
171+
" \"available\" if tf.config.list_physical_devices(\"GPU\") else \"NOT AVAILABLE\")"
186172
]
187173
},
188174
{
@@ -449,10 +435,6 @@
449435
},
450436
"outputs": [],
451437
"source": [
452-
"# This is necessary because hub.KerasLayer assumes tensor hashability, which\n",
453-
"# is not supported in eager mode.\n",
454-
"tf.compat.v1.disable_tensor_equality()\n",
455-
"\n",
456438
"pretrained_embedding = 'https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1'\n",
457439
"\n",
458440
"hub_layer = hub.KerasLayer(\n",

g3doc/tutorials/graph_keras_mlp_cora.ipynb

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,7 @@
115115
"id": "hgSLDi0SyBuO"
116116
},
117117
"source": [
118-
"1. Install TensorFlow 2.0.x to create an interactive development environment with eager execution.\n",
119-
"2. Install the Neural Structured Learning package."
120-
]
121-
},
122-
{
123-
"cell_type": "code",
124-
"execution_count": 0,
125-
"metadata": {
126-
"colab": {},
127-
"colab_type": "code",
128-
"id": "gh6K6Onyy5bd"
129-
},
130-
"outputs": [],
131-
"source": [
132-
"!pip install tensorflow-gpu==2.0.1"
118+
"Install the Neural Structured Learning package."
133119
]
134120
},
135121
{
@@ -174,7 +160,9 @@
174160
"\n",
175161
"print(\"Version: \", tf.__version__)\n",
176162
"print(\"Eager mode: \", tf.executing_eagerly())\n",
177-
"print(\"GPU is\", \"available\" if tf.test.is_gpu_available() else \"NOT AVAILABLE\")"
163+
"print(\n",
164+
" \"GPU is\",\n",
165+
" \"available\" if tf.config.list_physical_devices(\"GPU\") else \"NOT AVAILABLE\")"
178166
]
179167
},
180168
{

0 commit comments

Comments
 (0)