Source Code Generation with Generative Adversarial Networks (SeqGAN)
- Tensorflow r0.11
- Cuda 7.5 or higher (for GPU)
- nltk python package
Apply Generative Adversarial Nets to generating source code.
The illustration of SeqGAN. Left: D is trained over the real data and the generated data by G. Right: G is trained by policy gradient where the final reward signal is provided by D and is passed back to the intermediate action value via Monte Carlo search.
The research paper SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient has been accepted at the Thirty-First AAAI Conference on Artificial Intelligence (AAAI-17). The final version of the paper will be updated soon.
We provide example codes to repeat the synthetic data experiments with oracle evaluation mechanisms. Move to codegan-pg folder and run
python pretrain_experiment.py
will start maximum likelihood training with default parameters. In the same folder, run
python sequence_gan.py
will start SeqGAN training.
Note: this code is based on the previous work by ofirnachum. Many thanks to ofirnachum.
After running the experiments, the learning curve should be like this: