bioinf-jku/TTUR

Error in computing fid during training. ValueError: Cannot iterate over a shape with unknown rank.

Ayesha-Rafiq opened this issue · 13 comments

Error in computing fid during training. ValueError: Cannot iterate over a shape with unknown rank.

Epoch: [ 0] [ 0/ 305] time: 14.0901, d_loss: 1.75800323, g_loss: 0.26850128
[Sample] d_loss: 1.03988624, g_loss: 1.53502333
samples for incept 2/2 ok
Traceback (most recent call last):
File "main.py", line 161, in
tf.app.run()
File "C:\Users\Waqar\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "main.py", line 144, in main
dcgan.train(FLAGS)
File "D:\downloads\TTUR-master\TTUR-master\DCGAN_FID_batched\model.py", line 381, in train
verbose=self.fid_verbose)
File "D:\downloads\TTUR-master\TTUR-master\DCGAN_FID_batched\fid.py", line 175, in calculate_activation_statistics
act = get_activations(images, sess, batch_size, verbose)
File "D:\downloads\TTUR-master\TTUR-master\DCGAN_FID_batched\fid.py", line 82, in get_activations
inception_layer = _get_inception_layer(sess)
File "D:\downloads\TTUR-master\TTUR-master\DCGAN_FID_batched\fid.py", line 55, in _get_inception_layer
shape = [s.value for s in shape]
File "C:\Users\Waqar\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 497, in iter
raise ValueError("Cannot iterate over a shape with unknown rank.")
ValueError: Cannot iterate over a shape with unknown rank.

mhex commented

Hi, which Tensorflow version do you use?

My tensorflow version is 1.4.0

mhex???

Hi!
Could you try to change to a more recent version of tf? we had to adapt the code for newer tf versions - so hopefully this will fix the problem.

I have the same problem (both this and #8). @HRamses, Could you tell me the version of Tensorflow you have tested?

I tested it with version 1.8.0. But I tested it only on an separate data set and not while training. I will try to reproduce the error.

mhex commented

It looks like the code is not compatible anymore with the recent Python, Numpy? and Tensorflow versions. We need some time to sort this out.

untom commented

If you need a more short-term solution, please note that you can use the FID implementation from tensorflow contrib: https://www.tensorflow.org/api_docs/python/tf/contrib/gan/eval/frechet_classifier_distance

I also got this error using TF version 1.10 and python version 3.6.

I haven't tested this, but a fix that stops things from crashing and seems to give correct numbers is to replace line 54:

if shape._dims != []:

with:

if shape._dims != [] and (shape._dims is not None):