From 7130b117b5c9e36321eae32d61fedde2cd27185b Mon Sep 17 00:00:00 2001 From: Moonkwanghyun Date: Tue, 6 Nov 2018 19:31:21 +0900 Subject: [PATCH 1/4] Fix : name global_variables_initialize global_variables_initializer() to tf.global_variables_initializer() --- create_model_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_model_1.py b/create_model_1.py index 28fb02f..036e89d 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() From 71b55884f5e03afdefd770f931a4fdde96a9aaad Mon Sep 17 00:00:00 2001 From: Moonkwanghyun Date: Tue, 6 Nov 2018 19:32:48 +0900 Subject: [PATCH 2/4] Fix Parent directory of model.ckpt doesn't exis ValueError: Parent directory of model.ckpt doesn't exist, can't save_path = saver.save(sess, "model.ckpt") to save_path = saver.save(sess, "./model.ckpt") --- create_model_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_model_1.py b/create_model_1.py index 036e89d..ea8a795 100644 --- a/create_model_1.py +++ b/create_model_1.py @@ -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) From d4fb378d725449cf6b2048403ffb7856f6ad58bf Mon Sep 17 00:00:00 2001 From: Moonkwanghyun Date: Tue, 6 Nov 2018 19:49:11 +0900 Subject: [PATCH 3/4] Fix create_model_2.py Fix Parent directory of model.ckpt doesn't exis Fix : name global_variables_initialize --- create_model_2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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={ From ba27dc733ff28fc2a7aa3d0dd2a1dc7c2da28427 Mon Sep 17 00:00:00 2001 From: Moonkwanghyun Date: Wed, 7 Nov 2018 11:30:39 +0900 Subject: [PATCH 4/4] Fix typo in predict2 --- predict_2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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