diff --git a/imagenet/__pycache__/model.cpython-36.pyc b/imagenet/__pycache__/model.cpython-36.pyc new file mode 100644 index 0000000..cac7433 Binary files /dev/null and b/imagenet/__pycache__/model.cpython-36.pyc differ diff --git a/imagenet/__pycache__/ops.cpython-36.pyc b/imagenet/__pycache__/ops.cpython-36.pyc new file mode 100644 index 0000000..e136997 Binary files /dev/null and b/imagenet/__pycache__/ops.cpython-36.pyc differ diff --git a/imagenet/__pycache__/utils.cpython-36.pyc b/imagenet/__pycache__/utils.cpython-36.pyc new file mode 100644 index 0000000..5d199c6 Binary files /dev/null and b/imagenet/__pycache__/utils.cpython-36.pyc differ diff --git a/imagenet/convert_imagenet_to_records.py b/imagenet/convert_imagenet_to_records.py index 79d4122..c1c24af 100644 --- a/imagenet/convert_imagenet_to_records.py +++ b/imagenet/convert_imagenet_to_records.py @@ -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) @@ -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), @@ -66,4 +66,3 @@ def main(argv): if __name__ == "__main__": tf.app.run() - diff --git a/imagenet/discriminator.py b/imagenet/discriminator.py index 57e9708..219ad4e 100644 --- a/imagenet/discriminator.py +++ b/imagenet/discriminator.py @@ -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)) diff --git a/imagenet/generator.py b/imagenet/generator.py index f4a9860..867019c 100644 --- a/imagenet/generator.py +++ b/imagenet/generator.py @@ -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, @@ -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: @@ -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: @@ -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: @@ -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) diff --git a/imagenet/model.py b/imagenet/model.py index 9adb692..fe9e01d 100644 --- a/imagenet/model.py +++ b/imagenet/model.py @@ -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): """ @@ -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: @@ -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 diff --git a/imagenet/ops.py b/imagenet/ops.py index 0662954..8d536a6 100644 --- a/imagenet/ops.py +++ b/imagenet/ops.py @@ -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() @@ -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)