Unverified Commit 7d0fcd09 authored by Billy Lamberta's avatar Billy Lamberta Committed by GitHub
Browse files

Merge pull request #4766 from MarkDaoust/autopgraph-guide

Add clarifications 
parents c5b8f2f1 a73c656a
......@@ -5,8 +5,6 @@
"colab": {
"name": "autograph.ipynb",
"version": "0.3.2",
"views": {},
"default_view": {},
"provenance": [],
"private_outputs": true,
"collapsed_sections": [
......@@ -36,12 +34,7 @@
"metadata": {
"id": "llMNufAK7nfK",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -116,12 +109,7 @@
"metadata": {
"id": "RSez0n7Ptcvb",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -144,12 +132,7 @@
"metadata": {
"id": "mT7meGqrZTz9",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -177,12 +160,7 @@
"metadata": {
"id": "ks_hiqcSJNvg",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -217,12 +195,7 @@
"metadata": {
"id": "aA3gOodCBkOw",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -250,12 +223,7 @@
"metadata": {
"id": "_EMhGUjRZoKQ",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -278,12 +246,7 @@
"metadata": {
"id": "I1RtBvoKBxq5",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -306,12 +269,7 @@
"metadata": {
"id": "SGjSq0WQvwGs",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -342,12 +300,7 @@
"metadata": {
"id": "toxKBOXbB1ro",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -375,12 +328,7 @@
"metadata": {
"id": "jlyQgxYsYSXr",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -405,12 +353,7 @@
"metadata": {
"id": "BKhFNXDic4Mw",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -467,12 +410,7 @@
"metadata": {
"id": "IAOgh62zCPZ4",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -507,12 +445,7 @@
"metadata": {
"id": "ySTsuxnqCTQi",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -547,12 +480,7 @@
"metadata": {
"id": "ABX070KwCczR",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -591,12 +519,7 @@
"metadata": {
"id": "4yyNOf-Twr6s",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -631,12 +554,7 @@
"metadata": {
"id": "ucmZyQVL03bF",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -667,12 +585,7 @@
"metadata": {
"id": "1sjaFcL717Ig",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -728,12 +641,7 @@
"metadata": {
"id": "xqoxumv0ssQW",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -756,12 +664,7 @@
"metadata": {
"id": "Pe-erWQdBoC5",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -786,6 +689,9 @@
"\n",
"def fit(m, x, y, opt):\n",
" l, accuracy = predict(m, x, y)\n",
" # Autograph automatically adds the necessary `tf.control_dependencies` here.\n",
" # (Without them nothing depends on `opt.minimize`, so it doesn't run.)\n",
" # This makes it much more like eager-code.\n",
" opt.minimize(l)\n",
" return l, accuracy\n",
"\n",
......@@ -826,15 +732,12 @@
"metadata": {
"id": "3xtg_MMhJETd",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
"# Use `recursive = True` to recursively convert functions called by this one.\n",
"@autograph.convert(recursive=True)\n",
"def train(train_ds, test_ds, hp):\n",
" m = mlp_model((28 * 28,))\n",
" opt = tf.train.MomentumOptimizer(hp.learning_rate, 0.9)\n",
......@@ -893,12 +796,7 @@
"metadata": {
"id": "HYh6MSZyJOag",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
......@@ -909,9 +807,8 @@
" )\n",
" train_ds = setup_mnist_data(True, 50)\n",
" test_ds = setup_mnist_data(False, 1000)\n",
" tf_train = autograph.to_graph(train)\n",
" (train_losses, test_losses, train_accuracies,\n",
" test_accuracies) = tf_train(train_ds, test_ds, hp)\n",
" test_accuracies) = train(train_ds, test_ds, hp)\n",
"\n",
" init = tf.global_variables_initializer()\n",
" \n",
......@@ -940,4 +837,4 @@
"outputs": []
}
]
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment