Skip to content

Commit

Permalink
print predict and expect
Browse files Browse the repository at this point in the history
  • Loading branch information
JackonYang committed Mar 7, 2017
1 parent d215581 commit f9ad1da
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion simple_softmax.py
@@ -1,5 +1,6 @@
import argparse
import sys
import numpy as np

import input_data

Expand All @@ -22,6 +23,9 @@ def main(_):
b = tf.Variable(tf.zeros([y_len]))
y = tf.matmul(x, W) + b

# forword prop
predict = tf.argmax(y, axis=1)

# Define loss and optimizer
y_ = tf.placeholder(tf.float32, [None, y_len])
cross_entropy = tf.reduce_mean(
Expand All @@ -44,7 +48,11 @@ def main(_):
tf.cast(correct_prediction, tf.float32))
r = sess.run(accuracy, feed_dict={x: test_data.images,
y_: test_data.labels})
print 'step %s: %.2f%%' % (_, r * 100)
print 'step = %s, accuracy = %.2f%%' % (_, r * 100)

a = sess.run(predict, feed_dict={x: test_data.images[-10:]})
print 'predict: %s' % a
print 'expect : %s ' % np.argmax(test_data.labels[-10:], axis=1)


if __name__ == '__main__':
Expand Down

0 comments on commit f9ad1da

Please sign in to comment.