Skip to content

Commit 5e55342

Browse files
Kulbearaymericdamien
authored andcommitted
Add tensorboard_advanced.ipynb (aymericdamien#152)
* Make print function Python 3 compatible * Add notebook for tensorboard advanced tutorial
1 parent 31aa360 commit 5e55342

4 files changed

Lines changed: 326 additions & 55 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Note: If you are using older TensorFlow version (before 0.12), please have a [lo
3131
#### 4 - Utilities
3232
- Save and Restore a model ([notebook](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/save_restore_model.ipynb)) ([code](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/save_restore_model.py))
3333
- Tensorboard - Graph and loss visualization ([notebook](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/tensorboard_basic.ipynb)) ([code](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/tensorboard_basic.py))
34-
- Tensorboard - Advanced visualization ([code](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/tensorboard_advanced.py))
34+
- Tensorboard - Advanced visualization
35+
([notebook](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/tensorboard_advanced.ipynb)) ([code](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/tensorboard_advanced.py))
3536

3637
#### 5 - Multi GPU
3738
- Basic Operations on multi-GPU ([notebook](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/5_MultiGPU/multigpu_basics.ipynb)) ([code](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/5_MultiGPU/multigpu_basics.py))

notebooks/4_Utils/save_restore_model.ipynb

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
{
2222
"cell_type": "code",
2323
"execution_count": 1,
24-
"metadata": {
25-
"collapsed": false
26-
},
24+
"metadata": {},
2725
"outputs": [
2826
{
2927
"name": "stdout",
@@ -37,6 +35,8 @@
3735
}
3836
],
3937
"source": [
38+
"from __future__ import print_function\n",
39+
"\n",
4040
"# Import MINST data\n",
4141
"from tensorflow.examples.tutorials.mnist import input_data\n",
4242
"mnist = input_data.read_data_sets(\"MNIST_data/\", one_hot=True)\n",
@@ -47,9 +47,7 @@
4747
{
4848
"cell_type": "code",
4949
"execution_count": 3,
50-
"metadata": {
51-
"collapsed": false
52-
},
50+
"metadata": {},
5351
"outputs": [],
5452
"source": [
5553
"# Parameters\n",
@@ -119,9 +117,7 @@
119117
{
120118
"cell_type": "code",
121119
"execution_count": 5,
122-
"metadata": {
123-
"collapsed": false
124-
},
120+
"metadata": {},
125121
"outputs": [
126122
{
127123
"name": "stdout",
@@ -139,7 +135,7 @@
139135
],
140136
"source": [
141137
"# Running first session\n",
142-
"print \"Starting 1st session...\"\n",
138+
"print(\"Starting 1st session...\")\n",
143139
"with tf.Session() as sess:\n",
144140
" # Initialize variables\n",
145141
" sess.run(init)\n",
@@ -160,25 +156,23 @@
160156
" if epoch % display_step == 0:\n",
161157
" print \"Epoch:\", '%04d' % (epoch+1), \"cost=\", \\\n",
162158
" \"{:.9f}\".format(avg_cost)\n",
163-
" print \"First Optimization Finished!\"\n",
159+
" print(\"First Optimization Finished!\")\n",
164160
"\n",
165161
" # Test model\n",
166162
" correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))\n",
167163
" # Calculate accuracy\n",
168164
" accuracy = tf.reduce_mean(tf.cast(correct_prediction, \"float\"))\n",
169-
" print \"Accuracy:\", accuracy.eval({x: mnist.test.images, y: mnist.test.labels})\n",
165+
" print(\"Accuracy:\", accuracy.eval({x: mnist.test.images, y: mnist.test.labels}))\n",
170166
"\n",
171167
" # Save model weights to disk\n",
172168
" save_path = saver.save(sess, model_path)\n",
173-
" print \"Model saved in file: %s\" % save_path"
169+
" print(\"Model saved in file: %s\" % save_path)"
174170
]
175171
},
176172
{
177173
"cell_type": "code",
178174
"execution_count": 6,
179-
"metadata": {
180-
"collapsed": false
181-
},
175+
"metadata": {},
182176
"outputs": [
183177
{
184178
"name": "stdout",
@@ -200,14 +194,14 @@
200194
],
201195
"source": [
202196
"# Running a new session\n",
203-
"print \"Starting 2nd session...\"\n",
197+
"print(\"Starting 2nd session...\")\n",
204198
"with tf.Session() as sess:\n",
205199
" # Initialize variables\n",
206200
" sess.run(init)\n",
207201
"\n",
208202
" # Restore model weights from previously saved model\n",
209203
" load_path = saver.restore(sess, model_path)\n",
210-
" print \"Model restored from file: %s\" % save_path\n",
204+
" print(\"Model restored from file: %s\" % save_path)\n",
211205
"\n",
212206
" # Resume training\n",
213207
" for epoch in range(7):\n",
@@ -223,16 +217,16 @@
223217
" avg_cost += c / total_batch\n",
224218
" # Display logs per epoch step\n",
225219
" if epoch % display_step == 0:\n",
226-
" print \"Epoch:\", '%04d' % (epoch + 1), \"cost=\", \\\n",
227-
" \"{:.9f}\".format(avg_cost)\n",
228-
" print \"Second Optimization Finished!\"\n",
220+
" print(\"Epoch:\", '%04d' % (epoch + 1), \"cost=\", \\\n",
221+
" \"{:.9f}\".format(avg_cost))\n",
222+
" print(\"Second Optimization Finished!\")\n",
229223
"\n",
230224
" # Test model\n",
231225
" correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))\n",
232226
" # Calculate accuracy\n",
233227
" accuracy = tf.reduce_mean(tf.cast(correct_prediction, \"float\"))\n",
234-
" print \"Accuracy:\", accuracy.eval(\n",
235-
" {x: mnist.test.images, y: mnist.test.labels})"
228+
" print(\"Accuracy:\", accuracy.eval(\n",
229+
" {x: mnist.test.images, y: mnist.test.labels}))"
236230
]
237231
},
238232
{
@@ -247,23 +241,23 @@
247241
],
248242
"metadata": {
249243
"kernelspec": {
250-
"display_name": "Python 2",
244+
"display_name": "Python 3",
251245
"language": "python",
252-
"name": "python2"
246+
"name": "python3"
253247
},
254248
"language_info": {
255249
"codemirror_mode": {
256250
"name": "ipython",
257-
"version": 2
251+
"version": 3
258252
},
259253
"file_extension": ".py",
260254
"mimetype": "text/x-python",
261255
"name": "python",
262256
"nbconvert_exporter": "python",
263-
"pygments_lexer": "ipython2",
264-
"version": "2.7.13"
257+
"pygments_lexer": "ipython3",
258+
"version": "3.5.3"
265259
}
266260
},
267261
"nbformat": 4,
268-
"nbformat_minor": 0
262+
"nbformat_minor": 1
269263
}

0 commit comments

Comments
 (0)