You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/core/guide/autograph_control_flow.ipynb
+67-29Lines changed: 67 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@
10
10
"collapsed_sections": [
11
11
"Jxv6goXm7oGF"
12
12
],
13
+
"toc_visible": true,
13
14
"include_colab_link": true
14
15
},
15
16
"kernelspec": {
@@ -89,6 +90,16 @@
89
90
"[AutoGraph](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/autograph/README.md) helps you write complicated graph code using just plain Python -- behind the scenes, AutoGraph automatically transforms your code into the equivalent TF graph code. We support a large chunk of the Python language, which is growing. [Please see this document for what we currently support, and what we're working on](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/autograph/LIMITATIONS.md)."
90
91
]
91
92
},
93
+
{
94
+
"metadata": {
95
+
"id": "n4EKOpw9mObL",
96
+
"colab_type": "text"
97
+
},
98
+
"cell_type": "markdown",
99
+
"source": [
100
+
"### Setup"
101
+
]
102
+
},
92
103
{
93
104
"metadata": {
94
105
"id": "mT7meGqrZTz9",
@@ -103,12 +114,26 @@
103
114
"\n",
104
115
"import tensorflow as tf\n",
105
116
"from tensorflow.contrib import autograph\n",
117
+
"tf.enable_eager_execution()\n",
106
118
"\n",
107
119
"import matplotlib.pyplot as plt"
108
120
],
109
121
"execution_count": 0,
110
122
"outputs": []
111
123
},
124
+
{
125
+
"metadata": {
126
+
"id": "ohbSnA79mcJV",
127
+
"colab_type": "text"
128
+
},
129
+
"cell_type": "markdown",
130
+
"source": [
131
+
"## Automatically converting control flow\n",
132
+
"\n",
133
+
"AutoGraph can convert a large chunk of the Python language into equivalent graph-construction code, and we're adding new supported language features all the time. In this section, we'll give you a taste of some of the functionality in AutoGraph.\n",
134
+
"AutoGraph will automatically convert most Python control flow statements into their correct graph equivalent. "
135
+
]
136
+
},
112
137
{
113
138
"metadata": {
114
139
"id": "Ry0TlspBZVvf",
@@ -144,7 +169,7 @@
144
169
},
145
170
"cell_type": "markdown",
146
171
"source": [
147
-
"Into graph-compatible functions like this:"
172
+
"Into graph-building functions like this:"
148
173
]
149
174
},
150
175
{
@@ -167,7 +192,7 @@
167
192
},
168
193
"cell_type": "markdown",
169
194
"source": [
170
-
"You can take code written for eager execution and run it in graph mode. You get the same results, but with all the benfits of graphs:"
195
+
"You can take code written for eager execution and run it in a `tf.Graph`. You get the same results, but with all the benfits of graphs:"
"AutoGraph can convert a large chunk of the Python language into equivalent graph-construction code, and we're adding new supported language features all the time. In this section, we'll give you a taste of some of the functionality in AutoGraph.\n",
226
-
"AutoGraph will automatically convert most Python control flow statements into their correct graph equivalent. \n",
227
-
"\n",
228
-
"\n",
229
249
"We support common statements like `while`, `for`, `if`, `break`, `return` and more. You can even nest them as much as you like. Imagine trying to write the graph version of this code by hand:\n"
0 commit comments