Skip to content

Commit 1c57b09

Browse files
csferngtensorflow-copybara
authored andcommitted
Updates tutorials to use TF 2.0 release version.
PiperOrigin-RevId: 273627173
1 parent 7231909 commit 1c57b09

File tree

3 files changed

+72
-52
lines changed

3 files changed

+72
-52
lines changed

g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@
5151
"id": "wfqlePz0g6o5"
5252
},
5353
"source": [
54-
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
55-
" <td>\n",
56-
" <a target=\"_blank\" href=\"https://www.tensorflow.org/neural_structured_learning/tutorials/adversarial_keras_cnn_mnist\"><img src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" />View on TensorFlow.org</a>\n",
57-
" </td>\n",
58-
" <td>\n",
59-
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
60-
" </td>\n",
61-
" <td>\n",
62-
" <a target=\"_blank\" href=\"https://github.com/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
63-
" </td>\n",
64-
"</table>"
54+
"\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n",
55+
" \u003ctd\u003e\n",
56+
" \u003ca target=\"_blank\" href=\"https://www.tensorflow.org/neural_structured_learning/tutorials/adversarial_keras_cnn_mnist\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" /\u003eView on TensorFlow.org\u003c/a\u003e\n",
57+
" \u003c/td\u003e\n",
58+
" \u003ctd\u003e\n",
59+
" \u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n",
60+
" \u003c/td\u003e\n",
61+
" \u003ctd\u003e\n",
62+
" \u003ca target=\"_blank\" href=\"https://github.com/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView source on GitHub\u003c/a\u003e\n",
63+
" \u003c/td\u003e\n",
64+
"\u003c/table\u003e"
6565
]
6666
},
6767
{
@@ -115,7 +115,7 @@
115115
"id": "m58k8nv3YVdf"
116116
},
117117
"source": [
118-
"Install Tensorflow 2.0 to create an interactive developing environment with\n",
118+
"Select TensorFlow 2.x to create an interactive development environment with\n",
119119
"eager execution."
120120
]
121121
},
@@ -129,7 +129,11 @@
129129
},
130130
"outputs": [],
131131
"source": [
132-
"!pip install tensorflow-gpu==2.0.0-rc0"
132+
"try:\n",
133+
" # %tensorflow_version only exists in Colab.\n",
134+
" %tensorflow_version 2.x\n",
135+
"except Exception:\n",
136+
" !pip install --quiet tensorflow-gpu>=2.0.0"
133137
]
134138
},
135139
{
@@ -376,7 +380,7 @@
376380
" x = tf.keras.layers.Conv2D(\n",
377381
" num_filters, hparams.kernel_size, activation='relu')(\n",
378382
" x)\n",
379-
" if i < len(hparams.conv_filters) - 1:\n",
383+
" if i \u003c len(hparams.conv_filters) - 1:\n",
380384
" # max pooling between convolutional layers\n",
381385
" x = tf.keras.layers.MaxPooling2D(hparams.pool_size)(x)\n",
382386
" x = tf.keras.layers.Flatten()(x)\n",
@@ -800,25 +804,11 @@
800804
"timestamp": 1566174674305
801805
}
802806
],
803-
"toc_visible": true,
804-
"version": "0.3.2"
807+
"toc_visible": true
805808
},
806809
"kernelspec": {
807-
"display_name": "Python 3",
808-
"language": "python",
809-
"name": "python3"
810-
},
811-
"language_info": {
812-
"codemirror_mode": {
813-
"name": "ipython",
814-
"version": 3
815-
},
816-
"file_extension": ".py",
817-
"mimetype": "text/x-python",
818-
"name": "python",
819-
"nbconvert_exporter": "python",
820-
"pygments_lexer": "ipython3",
821-
"version": "3.7.3"
810+
"display_name": "Python 2",
811+
"name": "python2"
822812
}
823813
},
824814
"nbformat": 4,

g3doc/tutorials/graph_keras_lstm_imdb.ipynb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,26 @@
114114
"source": [
115115
"## Requirements\n",
116116
"\n",
117-
"1. Install TensorFlow 2.x to create an interactive developing environment with eager execution.\n",
118-
"2. Install the Neural Structured Learning package.\n",
119-
"3. Install tensorflow-hub."
117+
"1. Select TensorFlow 2.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+
"try:\n",
133+
" # %tensorflow_version only exists in Colab.\n",
134+
" %tensorflow_version 2.x\n",
135+
"except Exception:\n",
136+
" !pip install tensorflow-gpu>=2.0.0"
120137
]
121138
},
122139
{
@@ -129,7 +146,6 @@
129146
},
130147
"outputs": [],
131148
"source": [
132-
"!pip install --quiet tensorflow-gpu==2.0.0-rc0\n",
133149
"!pip install --quiet neural-structured-learning\n",
134150
"!pip install --quiet tensorflow-hub"
135151
]
@@ -1550,8 +1566,7 @@
15501566
"timestamp": 1566436775546
15511567
}
15521568
],
1553-
"toc_visible": true,
1554-
"version": "0.3.2"
1569+
"toc_visible": true
15551570
},
15561571
"kernelspec": {
15571572
"display_name": "Python 3",

g3doc/tutorials/graph_keras_mlp_cora.ipynb

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@
5151
"id": "pL9fF9FWI-Q1"
5252
},
5353
"source": [
54-
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
55-
" <td>\n",
56-
" <a target=\"_blank\" href=\"https://www.tensorflow.org/neural_structured_learning/tutorials/graph_keras_mlp_cora\"><img src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" />View on TensorFlow.org</a>\n",
57-
" </td>\n",
58-
" <td>\n",
59-
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/graph_keras_mlp_cora.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
60-
" </td>\n",
61-
" <td>\n",
62-
" <a target=\"_blank\" href=\"https://github.com/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/graph_keras_mlp_cora.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
63-
" </td>\n",
64-
"</table>"
54+
"\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n",
55+
" \u003ctd\u003e\n",
56+
" \u003ca target=\"_blank\" href=\"https://www.tensorflow.org/neural_structured_learning/tutorials/graph_keras_mlp_cora\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" /\u003eView on TensorFlow.org\u003c/a\u003e\n",
57+
" \u003c/td\u003e\n",
58+
" \u003ctd\u003e\n",
59+
" \u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/graph_keras_mlp_cora.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n",
60+
" \u003c/td\u003e\n",
61+
" \u003ctd\u003e\n",
62+
" \u003ca target=\"_blank\" href=\"https://github.com/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/graph_keras_mlp_cora.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView source on GitHub\u003c/a\u003e\n",
63+
" \u003c/td\u003e\n",
64+
"\u003c/table\u003e"
6565
]
6666
},
6767
{
@@ -116,10 +116,27 @@
116116
"id": "hgSLDi0SyBuO"
117117
},
118118
"source": [
119-
"1. Install TensorFlow 2.x to create an interactive developing environment with eager execution.\n",
119+
"1. Select TensorFlow 2.x to create an interactive development environment with eager execution.\n",
120120
"2. Install the Neural Structured Learning package."
121121
]
122122
},
123+
{
124+
"cell_type": "code",
125+
"execution_count": 0,
126+
"metadata": {
127+
"colab": {},
128+
"colab_type": "code",
129+
"id": "gh6K6Onyy5bd"
130+
},
131+
"outputs": [],
132+
"source": [
133+
"try:\n",
134+
" # %tensorflow_version only exists in Colab.\n",
135+
" %tensorflow_version 2.x\n",
136+
"except Exception:\n",
137+
" !pip install tensorflow-gpu>=2.0.0"
138+
]
139+
},
123140
{
124141
"cell_type": "code",
125142
"execution_count": 0,
@@ -130,7 +147,6 @@
130147
},
131148
"outputs": [],
132149
"source": [
133-
"!pip install --quiet tensorflow-gpu==2.0.0-rc0\n",
134150
"!pip install --quiet neural-structured-learning"
135151
]
136152
},
@@ -956,8 +972,7 @@
956972
"timestamp": 1560299386497
957973
}
958974
],
959-
"toc_visible": true,
960-
"version": "0.3.2"
975+
"toc_visible": true
961976
},
962977
"kernelspec": {
963978
"display_name": "Python 3",

0 commit comments

Comments
 (0)