openai / improved-gan

Code for the paper "Improved Techniques for Training GANs"

Home Page:https://arxiv.org/abs/1606.03498

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Batch size mismatch with Inception classifier

catherio opened this issue · comments

With Tensorflow 1.6.0, the line pred = sess.run(softmax, {'ExpandDims:0': inp}) raises an error because the input to the softmax in the Inception classifier expects a batch dimension of 1:

ValueError: Cannot feed value of shape (100, 32, 32, 3) for Tensor u'ExpandDims:0', which has shape '(1, ?, ?, 3)'

I assume this didn't used to be the case? For now I've patched my local fork to hardcode bs = 1, but I assume that's not the optimal fix here.

If I drop a breakpoint right before that line to show what I'm calling this with:

ipdb> len(images)
1000
ipdb> inp.shape
(100, 32, 32, 3)
ipdb> tf.get_default_graph().get_tensor_by_name("ExpandDims:0")
<tf.Tensor 'ExpandDims:0' shape=(1, ?, ?, 3) dtype=float32>

I have the same exact issue. I tried Tensorflow version 1.5 and 1.6 and it is same in both the cases. Really appreciate your help in resolving this.

I have the same issue.

Any updates on this issue?

An old version of tensorflow works.

Yes, tf version 1.3 works.

How should it work with tf version 1.3? It is not even working with version 1.2.1!
tensorflow/tensorflow#1021
With the provided model, only batch sizes of 1 are working.

commented

how to fix this issue with tf version 1.8 ?
thks

tf.contrib.gan.eval has functions that work in recent tensorflows.

Changing o._shape = ... to o.set_shape(...), as in #31, doesn't seem to have worked, because set_shape merges shape information instead of overriding it: tensorflow/tensorflow#5680 (comment)

Any updates on how to solve this? Or any alternatives?

Hi, Everyone
for those who still have a problem, please, make sure that images have a channel-last format (h x w x 3). I hope it may help ...
I had the same problem, I confused Pytorch with Tensorflow format.