29
29
"name" : " stdout" ,
30
30
"output_type" : " stream" ,
31
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 "
32
+ " Extracting MNIST_data /train-images-idx3-ubyte.gz\n " ,
33
+ " Extracting MNIST_data /train-labels-idx1-ubyte.gz\n " ,
34
+ " Extracting MNIST_data /t10k-images-idx3-ubyte.gz\n " ,
35
+ " Extracting MNIST_data /t10k-labels-idx1-ubyte.gz\n "
36
36
]
37
37
}
38
38
],
39
39
"source" : [
40
40
" # Import MINST data\n " ,
41
41
" from tensorflow.examples.tutorials.mnist import input_data\n " ,
42
- " mnist = input_data.read_data_sets(\" /tmp/data /\" , one_hot=True)\n " ,
42
+ " mnist = input_data.read_data_sets(\" MNIST_data /\" , one_hot=True)\n " ,
43
43
" \n " ,
44
44
" import tensorflow as tf"
45
45
]
92
92
},
93
93
{
94
94
"cell_type" : " code" ,
95
- "execution_count" : 4 ,
95
+ "execution_count" : 5 ,
96
96
"metadata" : {
97
- "collapsed" : true
97
+ "collapsed" : false
98
98
},
99
99
"outputs" : [],
100
100
"source" : [
114
114
" pred = multilayer_perceptron(x, weights, biases)\n " ,
115
115
" \n " ,
116
116
" # Define loss and optimizer\n " ,
117
- " cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, y))\n " ,
117
+ " cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits= pred, labels= y))\n " ,
118
118
" optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)\n " ,
119
119
" \n " ,
120
120
" # Initializing the variables\n " ,
121
- " init = tf.initialize_all_variables ()"
121
+ " init = tf.global_variables_initializer ()"
122
122
]
123
123
},
124
124
{
125
125
"cell_type" : " code" ,
126
- "execution_count" : 5 ,
126
+ "execution_count" : 6 ,
127
127
"metadata" : {
128
128
"collapsed" : false
129
129
},
132
132
"name" : " stdout" ,
133
133
"output_type" : " stream" ,
134
134
"text" : [
135
- " Epoch: 0001 cost= 185.342230390 \n " ,
136
- " Epoch: 0002 cost= 44.266946572 \n " ,
137
- " Epoch: 0003 cost= 27.999560453 \n " ,
138
- " Epoch: 0004 cost= 19.655567043 \n " ,
139
- " Epoch: 0005 cost= 14.284429696 \n " ,
140
- " Epoch: 0006 cost= 10.640310403 \n " ,
141
- " Epoch: 0007 cost= 7.904047886 \n " ,
142
- " Epoch: 0008 cost= 5.989115090 \n " ,
143
- " Epoch: 0009 cost= 4.689374613 \n " ,
144
- " Epoch: 0010 cost= 3.455884229 \n " ,
145
- " Epoch: 0011 cost= 2.733002625 \n " ,
146
- " Epoch: 0012 cost= 2.101091420 \n " ,
147
- " Epoch: 0013 cost= 1.496508092 \n " ,
148
- " Epoch: 0014 cost= 1.245452015 \n " ,
149
- " Epoch: 0015 cost= 0.912072906 \n " ,
135
+ " Epoch: 0001 cost= 173.056566575 \n " ,
136
+ " Epoch: 0002 cost= 44.054413928 \n " ,
137
+ " Epoch: 0003 cost= 27.455470655 \n " ,
138
+ " Epoch: 0004 cost= 19.008652363 \n " ,
139
+ " Epoch: 0005 cost= 13.654873594 \n " ,
140
+ " Epoch: 0006 cost= 10.059267435 \n " ,
141
+ " Epoch: 0007 cost= 7.436018432 \n " ,
142
+ " Epoch: 0008 cost= 5.587794416 \n " ,
143
+ " Epoch: 0009 cost= 4.209882509 \n " ,
144
+ " Epoch: 0010 cost= 3.203879515 \n " ,
145
+ " Epoch: 0011 cost= 2.319920681 \n " ,
146
+ " Epoch: 0012 cost= 1.676204545 \n " ,
147
+ " Epoch: 0013 cost= 1.248805338 \n " ,
148
+ " Epoch: 0014 cost= 1.052676844 \n " ,
149
+ " Epoch: 0015 cost= 0.890117338 \n " ,
150
150
" Optimization Finished!\n " ,
151
- " Accuracy: 0.9422 \n "
151
+ " Accuracy: 0.9459 \n "
152
152
]
153
153
}
154
154
],
181
181
" accuracy = tf.reduce_mean(tf.cast(correct_prediction, \" float\" ))\n " ,
182
182
" print \" Accuracy:\" , accuracy.eval({x: mnist.test.images, y: mnist.test.labels})"
183
183
]
184
+ },
185
+ {
186
+ "cell_type" : " code" ,
187
+ "execution_count" : null ,
188
+ "metadata" : {
189
+ "collapsed" : true
190
+ },
191
+ "outputs" : [],
192
+ "source" : []
184
193
}
185
194
],
186
195
"metadata" : {
192
201
"language_info" : {
193
202
"codemirror_mode" : {
194
203
"name" : " ipython" ,
195
- "version" : 2.0
204
+ "version" : 2
196
205
},
197
206
"file_extension" : " .py" ,
198
207
"mimetype" : " text/x-python" ,
199
208
"name" : " python" ,
200
209
"nbconvert_exporter" : " python" ,
201
210
"pygments_lexer" : " ipython2" ,
202
- "version" : " 2.7.11 "
211
+ "version" : " 2.7.13 "
203
212
}
204
213
},
205
214
"nbformat" : 4 ,
206
215
"nbformat_minor" : 0
207
- }
216
+ }
0 commit comments