Skip to content

Commit

Permalink
Update graph-NSL tutorials to i) use the default TF version in colab,…
Browse files Browse the repository at this point in the history
… which is currently TF 2.2.0-rc4, and ii) replace a deprecated API when checking for GPU availability.

PiperOrigin-RevId: 310414689
  • Loading branch information
arjung authored and tensorflow-copybara committed May 7, 2020
1 parent 9950642 commit edead04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 39 deletions.
28 changes: 5 additions & 23 deletions g3doc/tutorials/graph_keras_lstm_imdb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,8 @@
"source": [
"## Requirements\n",
"\n",
"1. Install TensorFlow 2.0.x to create an interactive development environment with eager execution.\n",
"2. Install the Neural Structured Learning package.\n",
"3. Install tensorflow-hub."
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "yDUe7gk_ztZ-"
},
"outputs": [],
"source": [
"!pip install tensorflow-gpu==2.0.1"
"1. Install the Neural Structured Learning package.\n",
"2. Install tensorflow-hub."
]
},
{
Expand Down Expand Up @@ -172,8 +158,6 @@
"import neural_structured_learning as nsl\n",
"\n",
"import tensorflow as tf\n",
"tf.compat.v1.enable_v2_behavior()\n",
"\n",
"import tensorflow_hub as hub\n",
"\n",
"# Resets notebook state\n",
Expand All @@ -182,7 +166,9 @@
"print(\"Version: \", tf.__version__)\n",
"print(\"Eager mode: \", tf.executing_eagerly())\n",
"print(\"Hub version: \", hub.__version__)\n",
"print(\"GPU is\", \"available\" if tf.test.is_gpu_available() else \"NOT AVAILABLE\")"
"print(\n",
" \"GPU is\",\n",
" \"available\" if tf.config.list_physical_devices(\"GPU\") else \"NOT AVAILABLE\")"
]
},
{
Expand Down Expand Up @@ -449,10 +435,6 @@
},
"outputs": [],
"source": [
"# This is necessary because hub.KerasLayer assumes tensor hashability, which\n",
"# is not supported in eager mode.\n",
"tf.compat.v1.disable_tensor_equality()\n",
"\n",
"pretrained_embedding = 'https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1'\n",
"\n",
"hub_layer = hub.KerasLayer(\n",
Expand Down
20 changes: 4 additions & 16 deletions g3doc/tutorials/graph_keras_mlp_cora.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,7 @@
"id": "hgSLDi0SyBuO"
},
"source": [
"1. Install TensorFlow 2.0.x to create an interactive development environment with eager execution.\n",
"2. Install the Neural Structured Learning package."
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "gh6K6Onyy5bd"
},
"outputs": [],
"source": [
"!pip install tensorflow-gpu==2.0.1"
"Install the Neural Structured Learning package."
]
},
{
Expand Down Expand Up @@ -174,7 +160,9 @@
"\n",
"print(\"Version: \", tf.__version__)\n",
"print(\"Eager mode: \", tf.executing_eagerly())\n",
"print(\"GPU is\", \"available\" if tf.test.is_gpu_available() else \"NOT AVAILABLE\")"
"print(\n",
" \"GPU is\",\n",
" \"available\" if tf.config.list_physical_devices(\"GPU\") else \"NOT AVAILABLE\")"
]
},
{
Expand Down

0 comments on commit edead04

Please sign in to comment.