Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
tal1977/tf_serving_example

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
vbezgachev committed May 9, 2018
2 parents f3dbe85 + 63a3d74 commit 1a48ab2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ __pycache__/
export/
.vscode/
*.pkl
*.pyc
1 change: 1 addition & 0 deletions dl_progress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from tqdm import tqdm

#https://github.com/tqdm/tqdm/blob/master/examples/tqdm_wget.py

class DLProgress(tqdm):
'''
Expand Down
4 changes: 2 additions & 2 deletions gan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requriments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tqdm
3 changes: 2 additions & 1 deletion svnh_semi_supervised_model_loaded_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
15 changes: 8 additions & 7 deletions svnh_semi_supervised_model_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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={
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 1a48ab2

Please sign in to comment.