CR-Gjx / LeakGAN

The codes of paper "Long Text Generation via Adversarial Training with Leaked Information" on AAAI 2018. Text generation using GAN and Hierarchical Reinforcement Learning.
https://arxiv.org/abs/1709.08624
576 stars 180 forks source link

python3 upgrade #1

Closed johndpope closed 6 years ago

johndpope commented 6 years ago

hi

(tensorflow) ➜ Synthetic Data git:(master) ✗ python Main.py

20
Traceback (most recent call last):
  File "Main.py", line 324, in <module>
    main()
  File "Main.py", line 170, in main
    target_params = cPickle.load(file.decode('utf-8'))
AttributeError: '_io.BufferedReader' object has no attribute 'decode'

(tensorflow) ➜ Synthetic Data git:(master) ✗ cd ..

I'm not sure if you can work it work it out. file = open('save/target_params.pkl', 'rb')

pickle fails to load pkl file.

CR-Gjx commented 6 years ago

OK, I can try to write a version of Python3 (depends on time), but you can run it in Python2 now, thank you.

Chillee commented 6 years ago

That's a pretty simple problem.

You just need to do target_params = pickle.load(open('save/target_params.pkl', 'rb'), encoding="latin1").

The bigger problem is that after fixing those issues, I'm getting

20
(64, ?, 1720)
(?, ?, 1720)
Traceback (most recent call last):
  File "Main.py", line 320, in <module>
    main()
  File "Main.py", line 173, in main
    learning_rate=LEARNING_RATE)
  File "/home/chilli/tmp/LeakGAN/Synthetic Data/LeakGANModel.py", line 250, in __init__
    self.pretrain_manager_updates = pretrain_manager_opt.apply_gradients(zip(self.pretrain_manager_grad, self.manager_params),global_step=global_step_pre)
  File "/usr/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 472, in apply_gradients
    ([str(v) for _, _, v in converted_grads_and_vars],))
ValueError: No gradients provided for any variable: ['<tensorflow.python.training.optimizer._RefVariableProcessor object at 0x7efff3be7320>', 

Any idea?

The reason for that is that on line 250 of LeakGANModel.py, self.pretrain_manager_grad gets set to an array of Nones.

Chillee commented 6 years ago

Actually, I fixed the necessary issues I think.

@CR-Gjx Do you think it's best for me to upload it to a separate repo or would you take some kind of PR?

Also, are there any details on what kind of hardware was used to train + how long it took?

Chillee commented 6 years ago

I've pushed my fork here. https://github.com/Chillee/LeakGAN

CR-Gjx commented 6 years ago

Thanks! In the Synthetic Data folder, it takes about 12 hours for 20-length texts and 24 hours for 40-length texts. In the Image Coco folder, it will take at least 12 hours to obtain a good effect. In addition, if you want to use this source code in other real datasets, you can use the source code in the Image Coco folder. Thanks again for your contribution.

Chillee commented 6 years ago

@CR-Gjx Wait, if you were trying to merge a python3 fork that worked, you merged the wrong one. I'm not the original OP of this pull request. I pushed my fork here: https://github.com/Chillee/LeakGAN

The current version you just merged in crashes in python 3, and I believe it also crashes for python 2.

johndpope commented 6 years ago

sorry @CR-Gjx - I created a revert PR @Chillee - please open up a new PR. thanks in advance