|
114 | 114 | "source": [ |
115 | 115 | "## Requirements\n", |
116 | 116 | "\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." |
133 | 119 | ] |
134 | 120 | }, |
135 | 121 | { |
|
172 | 158 | "import neural_structured_learning as nsl\n", |
173 | 159 | "\n", |
174 | 160 | "import tensorflow as tf\n", |
175 | | - "tf.compat.v1.enable_v2_behavior()\n", |
176 | | - "\n", |
177 | 161 | "import tensorflow_hub as hub\n", |
178 | 162 | "\n", |
179 | 163 | "# Resets notebook state\n", |
|
182 | 166 | "print(\"Version: \", tf.__version__)\n", |
183 | 167 | "print(\"Eager mode: \", tf.executing_eagerly())\n", |
184 | 168 | "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\")" |
186 | 172 | ] |
187 | 173 | }, |
188 | 174 | { |
|
449 | 435 | }, |
450 | 436 | "outputs": [], |
451 | 437 | "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", |
456 | 438 | "pretrained_embedding = 'https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1'\n", |
457 | 439 | "\n", |
458 | 440 | "hub_layer = hub.KerasLayer(\n", |
|
0 commit comments