Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = tf.placeholder(tf.float32, [None, 784])
- W = tf.Variable(tf.zeros([784, 10]))
- b = tf.Variable(tf.zeros([10]))
- y = tf.nn.softmax(tf.matmul(x, W) + b)
- y_ = tf.placeholder(tf.float32, [None, 10])
- cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
- train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
- sess = tf.InteractiveSession()
- tf.global_variables_initializer().run()
- correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
- accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
- print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))
- def train(data):
- global train_step, x, y
- trd = []
- # getting a letter from Option Menu
- l = dropVar.get()
- if l == 'a':
- trd = [1, 0, 0]
- # and so on
- sess.run(train_step, feed_dict={x: data, y_: trd})
- def test(data):
- global x, y_, y
- trd = []
- # getting a letter from Option Menu
- l = dropVar.get()
- if l == 'a':
- trd = [1, 0, 0]
- # and so on
- correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
- accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
- print(sess.run(accuracy, feed_dict={x: data, y_: trd}))
- # data is an image converted into a vector
Add Comment
Please, Sign In to add comment