progressive_growing_of_gans
progressive_growing_of_gans copied to clipboard
Minor Python 3 fixups.
Non-functional changes to run with Python 3.
Incremental printing looks uglier in python 3 unfortunately (print 'foo', => print('foo',end=' ')
), but the result should be the same.
ProGAN will also need some updates for CUDA 10/the next Tensorflow version, as they move one of the NCCL functions:
diff --git a/tfutil.py b/tfutil.py
index cf7ad0a..af970ed 100755
--- a/tfutil.py
+++ b/tfutil.py
@@ -13,6 +13,7 @@ import imp
import numpy as np
from collections import OrderedDict
import tensorflow as tf
+from tensorflow.python.ops import nccl_ops
#----------------------------------------------------------------------------
# Convenience.
@@ -328,7 +329,7 @@ class Optimizer:
for var_idx, grad_shape in enumerate(self._grad_shapes):
g = [dev_grads[dev][var_idx][0] for dev in devices]
if np.prod(grad_shape): # nccl does not support zero-sized tensors
- g = tf.contrib.nccl.all_sum(g)
+ g = nccl_ops.all_sum(g)
for dev, gg in zip(devices, g):
dev_grads[dev][var_idx] = (gg, dev_grads[dev][var_idx][1])