From 32b3dbf0fd848101e9855a0d2217be633b9177dd Mon Sep 17 00:00:00 2001 From: Kevin Xu Date: Sun, 14 Jan 2018 12:17:38 -0600 Subject: [PATCH 1/7] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8468d5a..f8e954a 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ This repo contains Tensorflow & deep learning projects. 2. Tensorflow, Keras # Where to find me (for Chinese readers)? -*  网易云课堂:http://study.163.com/provider/400000000275062/index.htm `(第一时间更新在这里).` +*  网易云课堂:http://study.163.com/provider/400000000275062/index.htm * Youtube: https://www.youtube.com/c/KevinXu * 微博: http://weibo.com/3983872447/profile -* 深度学习QQ群: 153032765 (人满), 2群:462661267(人满), 3群:264976854 +* 深度学习QQ群: 153032765 (人满), 2群:462661267(人满), 3群:264976854(人满),深度学习TF-4群:120983724 From fe013706953cbeb8713e35b27e23ea379afe4f52 Mon Sep 17 00:00:00 2001 From: hainingbaby Date: Mon, 11 Jun 2018 02:54:15 +0800 Subject: [PATCH 2/7] add evaluate_all_image() --- 01 cats vs dogs/training.py | 55 +++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/01 cats vs dogs/training.py b/01 cats vs dogs/training.py index decff16..8621183 100644 --- a/01 cats vs dogs/training.py +++ b/01 cats vs dogs/training.py @@ -161,8 +161,59 @@ def run_training(): # print('This is a cat with possibility %.6f' %prediction[:, 0]) # else: # print('This is a dog with possibility %.6f' %prediction[:, 1]) - - +# +def evaluate_all_image(): + ''' + Test all image against the saved models and parameters. + Return global accuracy of test_image_set + ############################################## + ##Notice that test image must has label to compare the prediction and real + ############################################## + ''' + # you need to change the directories to yours. + test_dir = '/home/kevin/tensorflow/cats_vs_dogs/data/test/' + N_CLASSES = 2 + print('-------------------------') + test, test_label = input_data.get_files(test_dir) + BATCH_SIZE = len(test) + print('There are %d test images totally..' % BATCH_SIZE) + print('-------------------------') + test_batch, test_label_batch = input_data.get_batch(test, + test_label, + IMG_W, + IMG_H, + BATCH_SIZE, + CAPACITY) + + logits = model.inference(test_batch, BATCH_SIZE, N_CLASSES) + testloss = model.losses(logits, test_label_batch) + testacc = model.evaluation(logits, test_label_batch) + + logs_train_dir = '/home/kevin/tensorflow/cats_vs_dogs/logs/train/' + saver = tf.train.Saver() + + with tf.Session() as sess: + print("Reading checkpoints...") + ckpt = tf.train.get_checkpoint_state(logs_train_dir) + if ckpt and ckpt.model_checkpoint_path: + global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1] + saver.restore(sess, ckpt.model_checkpoint_path) + print('Loading success, global_step is %s' % global_step) + else: + print('No checkpoint file found') + print('-------------------------') + coord = tf.train.Coordinator() + threads = tf.train.start_queue_runners(sess=sess, coord=coord) + test_loss,test_acc = sess.run([testloss,testacc]) + print('The model\'s loss is %.2f' %test_loss) + correct = int(BATCH_SIZE*test_acc) + print('Correct : %d' % correct) + print('Wrong : %d' % (BATCH_SIZE - correct)) + print('The accuracy in test images are %.2f%%' %(test_acc*100.0)) + coord.request_stop() + coord.join(threads) + sess.close() + #%% From 9be14735cf56f7d30fd9446e037d0a76784f1643 Mon Sep 17 00:00:00 2001 From: Kevin Xu Date: Thu, 19 Jul 2018 19:47:35 -0500 Subject: [PATCH 3/7] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f8e954a..47c0c53 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +## (Note that this repo is NOT going to be updated anymore, tensorflow version used in this repo was very old. -- July 19th, 2018) + # My-TensorFlow-tutorials This repo contains Tensorflow & deep learning projects. 1. Deep Learning (as well as traditional Machine Learning, Data Mining). From 963d78f463da9d565ec1a2c1f31297b3c47c1543 Mon Sep 17 00:00:00 2001 From: Guoqing Xu Date: Sun, 27 Jan 2019 10:27:09 -0600 Subject: [PATCH 4/7] Update train_and_val.py --- 01 cats vs dogs/new_version/train_and_val.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01 cats vs dogs/new_version/train_and_val.py b/01 cats vs dogs/new_version/train_and_val.py index c22ec23..1e8daa8 100644 --- a/01 cats vs dogs/new_version/train_and_val.py +++ b/01 cats vs dogs/new_version/train_and_val.py @@ -69,7 +69,7 @@ def run_training(): x = tf.placeholder(tf.float32, shape=[BATCH_SIZE, IMG_W, IMG_H, 3]) - y_ = tf.placeholder(tf.int16, shape=[BATCH_SIZE]) + y_ = tf.placeholder(tf.int32, shape=[BATCH_SIZE]) logits = model.inference(x, BATCH_SIZE, N_CLASSES) loss = model.losses(logits, y_) From f0474342fdcb8dc24308c48eb368fc26b8303bde Mon Sep 17 00:00:00 2001 From: Guoqing Xu Date: Mon, 11 Mar 2019 10:34:36 -0500 Subject: [PATCH 5/7] add feed_dict to sess.run - add feed_dict to sess.run(summary_op) --- 04 VGG Tensorflow/training_and_val.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/04 VGG Tensorflow/training_and_val.py b/04 VGG Tensorflow/training_and_val.py index ff98148..bc49782 100644 --- a/04 VGG Tensorflow/training_and_val.py +++ b/04 VGG Tensorflow/training_and_val.py @@ -92,7 +92,7 @@ def train(): feed_dict={x:tra_images, y_:tra_labels}) if step % 50 == 0 or (step + 1) == MAX_STEP: print ('Step: %d, loss: %.4f, accuracy: %.4f%%' % (step, tra_loss, tra_acc)) - summary_str = sess.run(summary_op) + summary_str = sess.run(summary_op, feed_dict={x:tra_images, y_:tra_labels}) tra_summary_writer.add_summary(summary_str, step) if step % 200 == 0 or (step + 1) == MAX_STEP: @@ -101,7 +101,7 @@ def train(): feed_dict={x:val_images,y_:val_labels}) print('** Step %d, val loss = %.2f, val accuracy = %.2f%% **' %(step, val_loss, val_acc)) - summary_str = sess.run(summary_op) + summary_str = sess.run(summary_op, feed_dict={x:tra_images, y_:tra_labels}) val_summary_writer.add_summary(summary_str, step) if step % 2000 == 0 or (step + 1) == MAX_STEP: From 4552a82b9444256437d7b9144023e5a2195a9f1d Mon Sep 17 00:00:00 2001 From: Guoqing Xu Date: Mon, 11 Mar 2019 10:41:20 -0500 Subject: [PATCH 6/7] add feed_dict when executing sess.run(summary_op) - add feed_dict when executing sess.run(summary_op) --- 01 cats vs dogs/new_version/train_and_val.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/01 cats vs dogs/new_version/train_and_val.py b/01 cats vs dogs/new_version/train_and_val.py index 1e8daa8..74b989a 100644 --- a/01 cats vs dogs/new_version/train_and_val.py +++ b/01 cats vs dogs/new_version/train_and_val.py @@ -98,7 +98,7 @@ def run_training(): feed_dict={x:tra_images, y_:tra_labels}) if step % 50 == 0: print('Step %d, train loss = %.2f, train accuracy = %.2f%%' %(step, tra_loss, tra_acc*100.0)) - summary_str = sess.run(summary_op) + summary_str = sess.run(summary_op, feed_dict={x:tra_images, y_:tra_labels}) train_writer.add_summary(summary_str, step) if step % 200 == 0 or (step + 1) == MAX_STEP: @@ -106,7 +106,7 @@ def run_training(): val_loss, val_acc = sess.run([loss, acc], feed_dict={x:val_images, y_:val_labels}) print('** Step %d, val loss = %.2f, val accuracy = %.2f%% **' %(step, val_loss, val_acc*100.0)) - summary_str = sess.run(summary_op) + summary_str = sess.run(summary_op, feed_dict={x:tra_images, y_:tra_labels}) val_writer.add_summary(summary_str, step) if step % 2000 == 0 or (step + 1) == MAX_STEP: From 27163a33599e314cc15670dcabf6be2a0106f4a3 Mon Sep 17 00:00:00 2001 From: Guoqing Xu Date: Sat, 30 Mar 2019 22:13:12 -0500 Subject: [PATCH 7/7] Update README.md --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 47c0c53..be9bd9b 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,8 @@ This repo contains Tensorflow & deep learning projects. 1. Deep Learning (as well as traditional Machine Learning, Data Mining). 2. Tensorflow, Keras -# Where to find me (for Chinese readers)? -*  网易云课堂:http://study.163.com/provider/400000000275062/index.htm * Youtube: https://www.youtube.com/c/KevinXu -* 微博: http://weibo.com/3983872447/profile -* 深度学习QQ群: 153032765 (人满), 2群:462661267(人满), 3群:264976854(人满),深度学习TF-4群:120983724 +