|
20 | 20 | },
|
21 | 21 | {
|
22 | 22 | "cell_type": "code",
|
23 |
| - "execution_count": 1, |
| 23 | + "execution_count": null, |
24 | 24 | "metadata": {
|
25 | 25 | "collapsed": false
|
26 | 26 | },
|
27 |
| - "outputs": [ |
28 |
| - { |
29 |
| - "name": "stdout", |
30 |
| - "output_type": "stream", |
31 |
| - "text": [ |
32 |
| - "Extracting /tmp/data/train-images-idx3-ubyte.gz\n", |
33 |
| - "Extracting /tmp/data/train-labels-idx1-ubyte.gz\n", |
34 |
| - "Extracting /tmp/data/t10k-images-idx3-ubyte.gz\n", |
35 |
| - "Extracting /tmp/data/t10k-labels-idx1-ubyte.gz\n" |
36 |
| - ] |
37 |
| - } |
38 |
| - ], |
| 27 | + "outputs": [], |
39 | 28 | "source": [
|
40 | 29 | "import tensorflow as tf\n",
|
41 | 30 | "\n",
|
42 | 31 | "# Import MINST data\n",
|
43 | 32 | "from tensorflow.examples.tutorials.mnist import input_data\n",
|
44 |
| - "mnist = input_data.read_data_sets(\"/tmp/data/\", one_hot=True)" |
| 33 | + "mnist = input_data.read_data_sets(\"MNIST_data/\", one_hot=True)" |
45 | 34 | ]
|
46 | 35 | },
|
47 | 36 | {
|
48 | 37 | "cell_type": "code",
|
49 |
| - "execution_count": 2, |
| 38 | + "execution_count": 6, |
50 | 39 | "metadata": {
|
51 | 40 | "collapsed": true
|
52 | 41 | },
|
|
72 | 61 | },
|
73 | 62 | {
|
74 | 63 | "cell_type": "code",
|
75 |
| - "execution_count": 3, |
| 64 | + "execution_count": 9, |
76 | 65 | "metadata": {
|
77 |
| - "collapsed": true |
| 66 | + "collapsed": false |
78 | 67 | },
|
79 | 68 | "outputs": [],
|
80 | 69 | "source": [
|
|
95 | 84 | " acc = tf.reduce_mean(tf.cast(acc, tf.float32))\n",
|
96 | 85 | "\n",
|
97 | 86 | "# Initializing the variables\n",
|
98 |
| - "init = tf.initialize_all_variables()\n", |
| 87 | + "init = tf.global_variables_initializer()\n", |
99 | 88 | "\n",
|
100 | 89 | "# Create a summary to monitor cost tensor\n",
|
101 |
| - "tf.scalar_summary(\"loss\", cost)\n", |
| 90 | + "tf.summary.scalar(\"loss\", cost)\n", |
102 | 91 | "# Create a summary to monitor accuracy tensor\n",
|
103 |
| - "tf.scalar_summary(\"accuracy\", acc)\n", |
| 92 | + "tf.summary.scalar(\"accuracy\", acc)\n", |
104 | 93 | "# Merge all summaries into a single op\n",
|
105 |
| - "merged_summary_op = tf.merge_all_summaries()" |
| 94 | + "merged_summary_op = tf.summary.merge_all()" |
106 | 95 | ]
|
107 | 96 | },
|
108 | 97 | {
|
109 | 98 | "cell_type": "code",
|
110 |
| - "execution_count": 4, |
| 99 | + "execution_count": 11, |
111 | 100 | "metadata": {
|
112 | 101 | "collapsed": false
|
113 | 102 | },
|
|
116 | 105 | "name": "stdout",
|
117 | 106 | "output_type": "stream",
|
118 | 107 | "text": [
|
119 |
| - "Epoch: 0001 cost= 1.182138957\n", |
120 |
| - "Epoch: 0002 cost= 0.664735104\n", |
121 |
| - "Epoch: 0003 cost= 0.552622685\n", |
122 |
| - "Epoch: 0004 cost= 0.498596912\n", |
123 |
| - "Epoch: 0005 cost= 0.465510372\n", |
124 |
| - "Epoch: 0006 cost= 0.442504281\n", |
125 |
| - "Epoch: 0007 cost= 0.425473650\n", |
126 |
| - "Epoch: 0008 cost= 0.412175615\n", |
127 |
| - "Epoch: 0009 cost= 0.401374554\n", |
128 |
| - "Epoch: 0010 cost= 0.392403109\n", |
129 |
| - "Epoch: 0011 cost= 0.384748503\n", |
130 |
| - "Epoch: 0012 cost= 0.378154479\n", |
131 |
| - "Epoch: 0013 cost= 0.372405099\n", |
132 |
| - "Epoch: 0014 cost= 0.367272844\n", |
133 |
| - "Epoch: 0015 cost= 0.362745077\n", |
134 |
| - "Epoch: 0016 cost= 0.358575674\n", |
135 |
| - "Epoch: 0017 cost= 0.354862829\n", |
136 |
| - "Epoch: 0018 cost= 0.351437834\n", |
137 |
| - "Epoch: 0019 cost= 0.348300697\n", |
138 |
| - "Epoch: 0020 cost= 0.345401101\n", |
139 |
| - "Epoch: 0021 cost= 0.342762216\n", |
140 |
| - "Epoch: 0022 cost= 0.340199728\n", |
141 |
| - "Epoch: 0023 cost= 0.337916089\n", |
142 |
| - "Epoch: 0024 cost= 0.335764083\n", |
143 |
| - "Epoch: 0025 cost= 0.333645939\n", |
| 108 | + "Epoch: 0001 cost= 1.182138961\n", |
| 109 | + "Epoch: 0002 cost= 0.664609327\n", |
| 110 | + "Epoch: 0003 cost= 0.552565036\n", |
| 111 | + "Epoch: 0004 cost= 0.498541865\n", |
| 112 | + "Epoch: 0005 cost= 0.465393374\n", |
| 113 | + "Epoch: 0006 cost= 0.442491178\n", |
| 114 | + "Epoch: 0007 cost= 0.425474149\n", |
| 115 | + "Epoch: 0008 cost= 0.412152022\n", |
| 116 | + "Epoch: 0009 cost= 0.401320939\n", |
| 117 | + "Epoch: 0010 cost= 0.392305281\n", |
| 118 | + "Epoch: 0011 cost= 0.384732356\n", |
| 119 | + "Epoch: 0012 cost= 0.378109478\n", |
| 120 | + "Epoch: 0013 cost= 0.372409370\n", |
| 121 | + "Epoch: 0014 cost= 0.367236996\n", |
| 122 | + "Epoch: 0015 cost= 0.362727492\n", |
| 123 | + "Epoch: 0016 cost= 0.358627345\n", |
| 124 | + "Epoch: 0017 cost= 0.354815522\n", |
| 125 | + "Epoch: 0018 cost= 0.351413656\n", |
| 126 | + "Epoch: 0019 cost= 0.348314827\n", |
| 127 | + "Epoch: 0020 cost= 0.345429416\n", |
| 128 | + "Epoch: 0021 cost= 0.342749324\n", |
| 129 | + "Epoch: 0022 cost= 0.340224642\n", |
| 130 | + "Epoch: 0023 cost= 0.337897302\n", |
| 131 | + "Epoch: 0024 cost= 0.335720168\n", |
| 132 | + "Epoch: 0025 cost= 0.333691911\n", |
144 | 133 | "Optimization Finished!\n",
|
145 | 134 | "Accuracy: 0.9143\n",
|
146 | 135 | "Run the command line:\n",
|
|
155 | 144 | " sess.run(init)\n",
|
156 | 145 | "\n",
|
157 | 146 | " # op to write logs to Tensorboard\n",
|
158 |
| - " summary_writer = tf.train.SummaryWriter(logs_path, graph=tf.get_default_graph())\n", |
| 147 | + " summary_writer = tf.summary.FileWriter(logs_path, graph=tf.get_default_graph())\n", |
159 | 148 | "\n",
|
160 | 149 | " # Training cycle\n",
|
161 | 150 | " for epoch in range(training_epochs):\n",
|
|
234 | 223 | ],
|
235 | 224 | "metadata": {
|
236 | 225 | "kernelspec": {
|
237 |
| - "display_name": "IPython (Python 2.7)", |
| 226 | + "display_name": "Python 2", |
238 | 227 | "language": "python",
|
239 | 228 | "name": "python2"
|
240 | 229 | },
|
|
248 | 237 | "name": "python",
|
249 | 238 | "nbconvert_exporter": "python",
|
250 | 239 | "pygments_lexer": "ipython2",
|
251 |
| - "version": "2.7.11" |
| 240 | + "version": "2.7.13" |
252 | 241 | }
|
253 | 242 | },
|
254 | 243 | "nbformat": 4,
|
|
0 commit comments