Commit d8e2929b authored by Yuxin Wu's avatar Yuxin Wu

small clean-ups

parent bf6402ad
......@@ -13,7 +13,6 @@ import tensorflow as tf
from tensorpack import *
from tensorpack.dataflow.dataset import ILSVRCMeta
from tensorpack.tfutils.summary import *
from tensorpack.tfutils.symbolic_functions import *
def tower_func(image):
......
......@@ -234,7 +234,8 @@ class EvalCallback(Callback):
shard=k, num_shards=self.num_predictor)
for k in range(self.num_predictor)]
else:
# Only eval on the first machine.
# Only eval on the first machine,
# Because evaluation assumes that all horovod workers share the filesystem.
# Alternatively, can eval on all ranks and use allgather, but allgather sometimes hangs
self._horovod_run_eval = hvd.rank() == hvd.local_rank()
if self._horovod_run_eval:
......
......@@ -70,7 +70,7 @@ class Model(DCGAN.Model):
# the gradient penalty loss
gradients = tf.gradients(vec_interp, [interp])[0]
gradients = tf.sqrt(tf.reduce_sum(tf.square(gradients), [1, 2, 3]))
gradients_rms = symbolic_functions.rms(gradients, 'gradient_rms')
gradients_rms = tf.sqrt(tf.reduce_mean(tf.square(gradients)), name='gradient_rms')
gradient_penalty = tf.reduce_mean(tf.square(gradients - 1), name='gradient_penalty')
add_moving_summary(self.d_loss, self.g_loss, gradient_penalty, gradients_rms)
......
# Generative Adversarial Networks
Reproduce the following GAN-related methods, 100~200 lines each:
Reproduce the following GAN-related methods, __100~200 lines each__:
+ DCGAN ([Unsupervised Representation Learning with DCGAN](https://arxiv.org/abs/1511.06434))
......
......@@ -28,7 +28,7 @@ def apply(model, model_path, images, ground_truth=None):
input_names=['left', 'right'],
output_names=['prediction']))
for right in images[1:]:
for idx, right in enumerate(images[1:]):
right = aug.augment(cv2.imread(right))
left_input, right_input = [x.astype('float32').transpose(2, 0, 1)[None, ...]
......@@ -43,7 +43,7 @@ def apply(model, model_path, images, ground_truth=None):
img = viz.stack_patches(patches, 2, 2)
cv2.imshow('flow output', img)
cv2.imwrite('flow_prediction.png', img)
cv2.imwrite('flow_output{:03d}.png'.format(idx), img)
cv2.waitKey(0)
left = right
......
......@@ -14,7 +14,6 @@ from tensorpack import *
from tensorpack.dataflow import dataset
from tensorpack.tfutils import gradproc, optimizer
from tensorpack.tfutils.summary import *
from tensorpack.tfutils.symbolic_functions import *
from tensorpack.utils import viz
from tensorpack.utils.gpu import get_num_gpu
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment