diff --git a/create_model_1.py b/create_model_1.py index 28fb02f..ea8a795 100644 --- a/create_model_1.py +++ b/create_model_1.py @@ -41,7 +41,7 @@ cross_entropy = -tf.reduce_sum(y_*tf.log(y)) train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy) -init_op = global_variables_initializer() +init_op = tf.global_variables_initializer() saver = tf.train.Saver() @@ -58,6 +58,6 @@ batch_xs, batch_ys = mnist.train.next_batch(100) sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys}) - save_path = saver.save(sess, "model.ckpt") + save_path = saver.save(sess, "./model.ckpt") print ("Model saved in file: ", save_path) diff --git a/create_model_2.py b/create_model_2.py index 4c3a965..f796f67 100644 --- a/create_model_2.py +++ b/create_model_2.py @@ -99,7 +99,7 @@ def max_pool_2x2(x): https://www.tensorflow.org/versions/master/how_tos/variables/index.html """ saver = tf.train.Saver() -sess.run(global_variables_initializer()) +sess.run(tf.global_variables_initializer()) #with tf.Session() as sess: #sess.run(init_op) for i in range(20000): @@ -110,7 +110,7 @@ def max_pool_2x2(x): print("step %d, training accuracy %g"%(i, train_accuracy)) train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5}) -save_path = saver.save(sess, "model2.ckpt") +save_path = saver.save(sess, "./model2.ckpt") print ("Model saved in file: ", save_path) print("test accuracy %g"%accuracy.eval(feed_dict={ diff --git a/predict_2.py b/predict_2.py index 2ca339d..c5d9ed4 100644 --- a/predict_2.py +++ b/predict_2.py @@ -114,8 +114,8 @@ def imageprepare(argv): if width > height: #check which dimension is bigger #Width is bigger. Width becomes 20 pixels. nheight = int(round((20.0/width*height),0)) #resize height according to ratio width - if (nheigth == 0): #rare case but minimum is 1 pixel - nheigth = 1 + if (nheight == 0): #rare case but minimum is 1 pixel + nheight = 1 # resize and sharpen img = im.resize((20,nheight), Image.ANTIALIAS).filter(ImageFilter.SHARPEN) wtop = int(round(((28 - nheight)/2),0)) #caculate horizontal pozition