weilinie / RelGAN

Implementation of RelGAN: Relational Generative Adversarial Networks for Text Generation
MIT License
120 stars 31 forks source link

Facing the error #16

Closed mmkjj closed 4 years ago

mmkjj commented 4 years ago

RelGAN\oracle\oracle_gan\oracle_train.py", line 265, in get_losses log_pg = tf.reduce_mean(tf.log(gen_o + EPS)) # [1], measures the log p_g(x) TypeError: unsupported operand type(s) for +: 'TensorArray' and 'float'

Actually it also happends in real_train.py I used the same environment ( Tensorflow1.4, python3.5) Why :(

weilinie commented 4 years ago

The error seems come from gen_o has not been properly converted to a Tensor from a TenorArray. Could you add gen_o.stack() in your code? I also updated the rmc_att and rmc_vdcnn in case that you were using them.

mmkjj commented 4 years ago

But after adding gen_o.stack(),Another Error happended:

\oracle\oracle_gan\oracle_train.py", line 314, in get_train_ops temp_train_op = temp_optimizer.apply_gradients(zip(temp_grads, [temperature])) lib\site-packages\tensorflow\python\training\optimizer.py", line 472, in applygradients ([str(v) for , _, v in converted_grads_and_vars],)) ValueError: No gradients provided for any variable: ['<tensorflow.python.training.optimizer._RefVariableProcessor object at 0x000001CF5ED1C390>'].

weilinie commented 4 years ago

Not sure where you added gen_o.stack(). Can you confirm if you are using rmc_att or rmc_vdcnn? If so, maybe you can pull it again and see if you can run properly.

mmkjj commented 4 years ago

I changed the get_losses() function in oracle_train.py: from log_pg = tf.reduce_mean(tf.log(gen_o + EPS)) to 'log_pg = tf.reduce_mean(tf.log(gen_o.stack() + EPS))' I used the default parameters, So I think that the generator and discriminator are both rmc_att, and type of the GAN is standard

weilinie commented 4 years ago

OK, there is something wrong with rmc_att and I fixed it. Also, I changed the default GAN architecture in run.py to rmc_vanilla, because all the experiments in the paper are based on rmc_vanilla actually. Can you pull it again?

mmkjj commented 4 years ago

I downloaded all of your new code again,. This time I think the default GAN architecture is rmc_vanilla. However it seems that I'm facing a new Error :

oracle\oracle_gan\oracle_train.py", line 355, in get_metric_summary_op metric_summary_op = tf.summary.merge(metrics_sum) lib\site-packages\tensorflow\python\summary\summary.py", line 271, in merge val = _gen_logging_ops._merge_summary(inputs=inputs, name=name) lib\site-packages\tensorflow\python\ops\gen_logging_ops.py", line 314, in _merge_summary "MergeSummary", inputs=inputs, name=name) lib\site-packages\tensorflow\python\framework\op_def_library.py", line 570, in _apply_op_helper (input_name, op_type_name, len(values), num_attr.minimum)) ValueError: List argument 'inputs' to 'MergeSummary' Op with length 0 shorter than minimum length 1.

weilinie commented 4 years ago

This is because all the metrics are set to False with the default setting in run.py (line 41-45). You can set at least one of the metrics to True to avoid this issue.

mmkjj commented 4 years ago

Oh,solved.. Thank you very much :)