sess = tf.InteractiveSession() sess.run(tf.initialize_all_variables()) for i in range(20000): batch_xs, batch_ys = load_data.get_train_batch(50) if i % 100 == 0: train_accuracy = accuracy.eval(feed_dict={ x: batch_xs, y_: batch_ys, keep_prob: 1.0}) print "step %d, training accuracy %g" % (i, train_accuracy) train_step.run(feed_dict={x: batch_xs, y_: batch_ys, keep_prob: 0.5}) #print "test accuracy %g"%accuracy.eval(feed_dict={ # x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}) test_set_x = load_data.load_test_data("/home/darshan/Documents/DigitRecognizer/MNIST_data/", "test.csv") print(test_set_x.shape) nbr_of_test_batches = 10 batch_size = load_data.nbr_of_test_dp / nbr_of_test_batches for j in xrange(nbr_of_test_batches): test_batch = load_data.get_test_batch(batch_size) if test_batch is not None: y_predict = tf.argmax(y_conv, 1) result_value = sess.run(y_predict, feed_dict={x: test_batch, keep_prob: 1.0}) result_label = xrange((batch_size * j) + 1, (batch_size * (j + 1)) + 1) z = np.array(zip(result_label, result_value), dtype=[('ImageId', int), ('Label', int)]) np.savetxt('result_cnn' + str(j) + '.csv', z, fmt='%i,%i') sess.close()