EmilienDupont / vae-concrete

Keras implementation of a Variational Auto Encoder with a Concrete Latent Distribution
51 stars 18 forks source link

shape mismatch #1

Closed andreiamatuni closed 6 years ago

andreiamatuni commented 6 years ago

when running main.py I get this error:

Caused by op u'loss_2/generated_loss/logistic_loss/mul', defined at:
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1599, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1026, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Users/andrei/code/third_party/vae-concrete/main.py", line 6, in <module>
    model.fit(x_train, num_epochs=1)
  File "/Users/andrei/code/third_party/vae-concrete/vae_concrete.py", line 62, in fit
    self.model.compile(optimizer=self.opt, loss=self._vae_loss)
  File "/usr/local/lib/python2.7/site-packages/keras/engine/training.py", line 850, in compile
    sample_weight, mask)
  File "/usr/local/lib/python2.7/site-packages/keras/engine/training.py", line 450, in weighted
    score_array = fn(y_true, y_pred)
  File "/Users/andrei/code/third_party/vae-concrete/vae_concrete.py", line 195, in _vae_loss
    binary_crossentropy(x, x_generated)
  File "/usr/local/lib/python2.7/site-packages/keras/losses.py", line 57, in binary_crossentropy
    return K.mean(K.binary_crossentropy(y_true, y_pred), axis=-1)
  File "/usr/local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2822, in binary_crossentropy
    logits=output)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/nn_impl.py", line 171, in sigmoid_cross_entropy_with_logits
    return math_ops.add(relu_logits - logits * labels,
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 838, in binary_op_wrapper
    return func(x, y, name=name)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 1061, in _mul_dispatch
    return gen_math_ops._mul(x, y, name=name)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1377, in _mul
    result = _op_def_lib.apply_op("Mul", x=x, y=y, name=name)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2506, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1269, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Incompatible shapes: [72900] vs. [78400]
     [[Node: loss_2/generated_loss/logistic_loss/mul = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](loss_2/generated_loss/Log, loss_2/generated_loss/Reshape)]]

also any plans to update for latest keras and tensorflow?

EmilienDupont commented 6 years ago

There was a bug in the generator (wrong padding at one of the layers), it's fixed now. I didn't use to have this bug before, so thanks for pointing it out! Also updated everything to latest keras and tensorflow.