Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed tab error #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added imagenet/__pycache__/model.cpython-36.pyc
Binary file not shown.
Binary file added imagenet/__pycache__/ops.cpython-36.pyc
Binary file not shown.
Binary file added imagenet/__pycache__/utils.cpython-36.pyc
Binary file not shown.
5 changes: 2 additions & 3 deletions imagenet/convert_imagenet_to_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main(argv):
writer = tf.python_io.TFRecordWriter(outfile)

for i, f in enumerate(files):
print i
print(i)
image = get_image(f, IMSIZE, is_crop=True, resize_w=IMSIZE)
image = colorize(image)
assert image.shape == (IMSIZE, IMSIZE, 3)
Expand All @@ -52,7 +52,7 @@ def main(argv):
class_str = f.split('/')[-2]
label = str_to_int[class_str]
if i % 1 == 0:
print i, '\t',label
print(i+'\t'+label)
example = tf.train.Example(features=tf.train.Features(feature={
'height': _int64_feature(IMSIZE),
'width': _int64_feature(IMSIZE),
Expand All @@ -66,4 +66,3 @@ def main(argv):

if __name__ == "__main__":
tf.app.run()

22 changes: 11 additions & 11 deletions imagenet/discriminator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,37 @@ def discriminator(self, image, reuse=False, y=None, prefix=""):
mean=0.0,
stddev=.1)

print "Discriminator shapes"
print "image: ", image.get_shape()
print("Discriminator shapes")
print("image: {0}".format(image.get_shape()))
def tower(bn, suffix):
assert not self.y_dim
print "\ttower "+suffix
print("\ttower "+suffix)
h0 = lrelu(bn(conv2d(noisy_image, self.df_dim, name='d_h0_conv' + suffix, d_h=2, d_w=2,
k_w=3, k_h=3), "d_bn_0" + suffix))
print "\th0 ", h0.get_shape()
print("\th0 {0}".format(h0.get_shape()))
h1 = lrelu(bn(conv2d(h0, self.df_dim * 2, name='d_h1_conv' + suffix, d_h=2, d_w=2,
k_w=3, k_h=3), "d_bn_1" + suffix))
print "\th1 ", h1.get_shape()
print("\th1 {0}".format(h1.get_shape()))
h2 = lrelu(bn(conv2d(h1, self.df_dim * 4, name='d_h2_conv' + suffix, d_h=2, d_w=2,
k_w=3, k_h=3), "d_bn_2" + suffix))
print "\th2 ", h2.get_shape()
print("\th2 {0}", h2.get_shape())

h3 = lrelu(bn(conv2d(h2, self.df_dim*4, name='d_h3_conv' + suffix, d_h=1, d_w=1,
k_w=3, k_h=3), "d_bn_3" + suffix))
print "\th3 ", h3.get_shape()
print("\th3 {0}".format(h3.get_shape()))
h4 = lrelu(bn(conv2d(h3, self.df_dim*4, name='d_h4_conv' + suffix, d_h=1, d_w=1,
k_w=3, k_h=3), "d_bn_4" + suffix))
print "\th4 ", h4.get_shape()
print("\th4 {0}".format(h4.get_shape()))
h5 = lrelu(bn(conv2d(h4, self.df_dim*8, name='d_h5_conv' + suffix, d_h=2, d_w=2,
k_w=3, k_h=3), "d_bn_5" + suffix))
print "\th5 ", h5.get_shape()
print("\th5 {0}".format(h5.get_shape())

h6 = lrelu(bn(conv2d(h5, self.df_dim*8, name='d_h6_conv' + suffix,
k_w=3, k_h=3), "d_bn_6" + suffix))
print "\th6 ", h6.get_shape()
print("\th6 {0}".format(h6.get_shape())
# return tf.reduce_mean(h6, [1, 2])
h6_reshaped = tf.reshape(h6, [batch_size, -1])
print '\th6_reshaped: ', h6_reshaped.get_shape()
print('\th6_reshaped: {0}'.format(h6_reshaped.get_shape()))

h7 = lrelu(bn(linear(h6_reshaped, self.df_dim * 40, scope="d_h7" + suffix), "d_bn_7" + suffix))

Expand Down
10 changes: 5 additions & 5 deletions imagenet/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def make_z(shape, minval, maxval, name, dtype):
initializer=tf.random_uniform_initializer(minval, maxval),
trainable=False)
if z.device != "/device:GPU:0":
print "z.device is " + str(z.device)
print("z.device is " + str(z.device))
assert False
else:
z = tf.random_uniform(shape,
Expand Down Expand Up @@ -109,7 +109,7 @@ def reuse_wrapper(packed, *args):
else:
h3_name = "h3_relu_reuse"
h3 = tf.nn.relu(dcgan.vbn(h3, "g_vbn_3"), name=h3_name)
print "h3 shape: ", h3.get_shape()
print("h3 shape: {0}".format(h3.get_shape()))

quarter = dcgan.gf_dim // 4
if quarter == 0:
Expand All @@ -127,7 +127,7 @@ def reuse_wrapper(packed, *args):
name='g_h4', with_w=make_vars),
'h4_w', 'h4_b')
h4 = tf.nn.relu(dcgan.vbn(h4, "g_vbn_4"))
print "h4 shape: ", h4.get_shape()
print("h4 shape: {0}".format(h4.get_shape()))

eighth = dcgan.gf_dim // 8
if eighth == 0:
Expand All @@ -143,7 +143,7 @@ def reuse_wrapper(packed, *args):
name='g_h5', with_w=make_vars),
'h5_w', 'h5_b')
h5 = tf.nn.relu(dcgan.vbn(h5, "g_vbn_5"))
print "h5 shape: ", h5.get_shape()
print("h5 shape: {0}".format(h5.get_shape()))

sixteenth = dcgan.gf_dim // 16
if sixteenth == 0:
Expand All @@ -161,7 +161,7 @@ def reuse_wrapper(packed, *args):
init_bias=dcgan.out_init_b,
stddev=dcgan.out_stddev),
'h6_w', 'h6_b')
print 'h6 shape: ', h6.get_shape()
print('h6 shape: {0}'.format(h6.get_shape()))

out = tf.nn.tanh(h6)

Expand Down
8 changes: 4 additions & 4 deletions imagenet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, sess, image_size=108, is_crop=True,
devices=None,
disable_vbn=False,
sample_size=64,
out_init_b=0.,
out_init_b=0.,
out_stddev=.15):
"""

Expand All @@ -44,8 +44,8 @@ def __init__(self, sess, image_size=108, is_crop=True,
self.disable_vbn = disable_vbn
self.devices = devices
self.d_label_smooth = d_label_smooth
self.out_init_b = out_init_b
self.out_stddev = out_stddev
self.out_init_b = out_init_b
self.out_stddev = out_stddev
self.config = config
self.generator_target_prob = generator_target_prob
if generator is not None:
Expand Down Expand Up @@ -226,7 +226,7 @@ def load(self, checkpoint_dir):
self.saver.restore(self.sess, os.path.join(checkpoint_dir, ckpt_name))
return True
else:
print "Bad checkpoint: ", ckpt
print("Bad checkpoint: {0}".format(ckpt))
return False


Expand Down
12 changes: 6 additions & 6 deletions imagenet/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, name="batch_norm", epsilon=1e-5, momentum=0.1,
global TRAIN_MODE
self.train = TRAIN_MODE
self.ema = tf.train.ExponentialMovingAverage(decay=0.9)
print "initing %s in train: %s" % (scope.name, self.train)
print ("initing {0} in train: {1}".format(scope.name, self.train))

def __call__(self, x):
shape = x.get_shape()
Expand Down Expand Up @@ -167,11 +167,11 @@ def special_deconv2d(input_, output_shape,

def check_shape(h_size, im_size, stride):
if h_size != (im_size + stride - 1) // stride:
print "Need h_size == (im_size + stride - 1) // stride"
print "h_size: ", h_size
print "im_size: ", im_size
print "stride: ", stride
print "(im_size + stride - 1) / float(stride): ", (im_size + stride - 1) / float(stride)
print ("Need h_size == (im_size + stride - 1) // stride")
print ("h_size: {0}".format(h_size))
print ("im_size: {0}".format(im_size))
print ("stride: {0}".format(stride))
print ("(im_size + stride - 1) / float(stride): {0}".format((im_size + stride - 1) / float(stride)))
raise ValueError()

check_shape(int(input_.get_shape()[1]), output_shape[1] + k_h, d_h)
Expand Down