diff --git a/.gitignore b/.gitignore index 2f8c403..f6a06be 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__/ export/ .vscode/ *.pkl +*.pyc diff --git a/dl_progress.py b/dl_progress.py index a8a6903..ffd9c53 100644 --- a/dl_progress.py +++ b/dl_progress.py @@ -1,5 +1,6 @@ from tqdm import tqdm +#https://github.com/tqdm/tqdm/blob/master/examples/tqdm_wget.py class DLProgress(tqdm): ''' diff --git a/gan.py b/gan.py index 2a850be..0844686 100644 --- a/gan.py +++ b/gan.py @@ -15,7 +15,7 @@ def __init__(self, input_real, z_size, learning_rate, num_classes=10, :param num_classes: The number of classes to recognize. :param alpha: The slope of the left half of the leaky ReLU activation :param beta1: The beta1 parameter for Adam. - :param drop_rate: RThe probability of dropping a hidden unit (used in discriminator) + :param drop_rate: The probability of dropping a hidden unit (used in discriminator) """ self.learning_rate = tf.Variable(learning_rate, trainable=False) @@ -257,7 +257,7 @@ def discriminator(self, x, drop_rate, reuse=False, alpha=0.2, num_classes=10, si # This trick and this value of m fix both those cases, but the naive implementation and # other values of m encounter various problems) - max_val = tf.reduce_max(class_logits, 1, keep_dims=True) + max_val = tf.reduce_max(class_logits, 1, keepdims=True) stable_class_logits = class_logits - max_val max_val = tf.squeeze(max_val) gan_logits = tf.log(tf.reduce_sum(tf.exp(stable_class_logits), 1)) + max_val diff --git a/requriments.txt b/requriments.txt new file mode 100644 index 0000000..78620c4 --- /dev/null +++ b/requriments.txt @@ -0,0 +1 @@ +tqdm diff --git a/svnh_semi_supervised_model_loaded_test.py b/svnh_semi_supervised_model_loaded_test.py index 9e131f3..797ab5a 100644 --- a/svnh_semi_supervised_model_loaded_test.py +++ b/svnh_semi_supervised_model_loaded_test.py @@ -86,11 +86,12 @@ def load_and_predict_with_saved_model(): scores = sess.run(output_tensor, {input_tensor: [image]}) # print results + print("Image file name: {}".format(image_file_name)) print("Scores: {}".format(scores)) def main(_): - # load_and_predict_with_checkpoints() + load_and_predict_with_checkpoints() load_and_predict_with_saved_model() diff --git a/svnh_semi_supervised_model_train.py b/svnh_semi_supervised_model_train.py index d794deb..1e47cf4 100644 --- a/svnh_semi_supervised_model_train.py +++ b/svnh_semi_supervised_model_train.py @@ -36,7 +36,7 @@ def train(net, dataset, epochs, batch_size, z_size): ''' saver = tf.train.Saver() - # noise to generate the fake images; it used used at the end + # noise to generate the fake images; it used at the end # of each epoch to check how good the generator is sample_z = np.random.normal(0, 1, size=(50, z_size)) @@ -47,7 +47,7 @@ def train(net, dataset, epochs, batch_size, z_size): with tf.Session() as sess: sess.run(tf.global_variables_initializer()) for e in range(epochs): - print("Epoch", e) + print("Epoch: {}".format(e)) t1e = time.time() num_examples = 0 @@ -73,7 +73,7 @@ def train(net, dataset, epochs, batch_size, z_size): # calcualte and print train statistic train_accuracy = num_correct / float(num_examples) - print("\t\tClassifier train accuracy: ", train_accuracy) + print("\t\tClassifier train accuracy: {}".format(train_accuracy)) # run prediction on test images num_examples = 0 @@ -88,10 +88,11 @@ def train(net, dataset, epochs, batch_size, z_size): # calculate and print test statistic test_accuracy = num_correct / float(num_examples) - print("\t\tClassifier test accuracy", test_accuracy) - print("\t\tStep time: ", t2 - t1) + print("\t\tClassifier test accuracy: {}".format(test_accuracy)) + print("\t\tStep : {}".format(steps)) + print("\t\tStep time: {}".format(t2 - t1)) t2e = time.time() - print("\t\tEpoch time: ", t2e - t1e) + print("\t\tEpoch time: {}".format(t2e - t1e)) # generate samples for visual check gen_samples = sess.run(net.samples, feed_dict={ @@ -123,7 +124,7 @@ def main(): learning_rate = 0.0003 tf.reset_default_graph() - input_real = tf.placeholder(tf.float32, (None, *real_size), name='input_real') + input_real = tf.placeholder(dtype=tf.float32, shape=(None,) + real_size, name='input_real') net = GAN(input_real, z_size, learning_rate) # craete dataset diff --git a/utils.py b/utils.py index f2ee950..9babd9b 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,8 @@ import os from os.path import isfile -from urllib.request import urlretrieve +from six.moves import urllib +#from urllib.request import urlretrieve +from urllib import urlretrieve from scipy.io import loadmat from dl_progress import DLProgress