igul222 / improved_wgan_training

Code for reproducing experiments in "Improved Training of Wasserstein GANs"
MIT License
2.35k stars 668 forks source link

o._shape = TensorShape(new_shape) caused error in inception_score.py #78

Closed yanzhicong closed 6 years ago

yanzhicong commented 6 years ago

the tensorflow 1.8.0 seems to have disabled this operation, it suggest to use the set_shape function:

o._shape = tf.TensorShape(new_shape)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 434, in _shape
    "Tensor._shape cannot be assigned, use Tensor.set_shape instead.")
ValueError: Tensor._shape cannot be assigned, use Tensor.set_shape instead

but when I use the set_shape function I found the tensor shape is not changed. I print this:

 o.set_shape(tf.TensorShape(new_shape))
 print(o.name, shape, new_shape, o.get_shape())

the output shows the tensor shape is not changed by this function:

ExpandDims/dim:0 [1] [None] (1,)
DecodeJpeg/contents:0 [] [] ()
DecodeJpeg:0 [None, None, 3] [None, None, 3] (?, ?, 3)
Cast:0 [None, None, 3] [None, None, 3] (?, ?, 3)
ExpandDims:0 [1, None, None, 3] [None, None, None, 3] (1, ?, ?, 3)
ResizeBilinear:0 [1, 299, 299, 3] [None, 299, 299, 3] (1, 299, 299, 3)
yanzhicong commented 6 years ago

refer to this link https://stackoverflow.com/questions/49525530/gan-training-cannot-calculate-inception-score-because-of-tensor-set-shape-error