Coder Social home page Coder Social logo

seqgan-pytorch's Introduction

SeqGAN-PyTorch

A implementation of SeqGAN in PyTorch, following the implementation in tensorflow.

Tested with:

  • PyTorch v1 Stable
  • Python 3.6
  • CUDA at least 8.0 (For GPU)

Origin

The idea is from paper SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient

The code is rewrited in PyTorch with the structure largely from Tensorflow Implementation

Runing

$ python main.py

After runing this file, the results will be printed on terminal. You can change the parameters in the main.py.

seqgan-pytorch's People

Contributors

hija avatar zijianzhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

seqgan-pytorch's Issues

Why are you adding zero to your data and target?

Hello,
I have run your code, and I noticed that when you pretrain the generator, you prepend a zero matrix to the data and append a zero matrix to the target. I wonder what is the purpose of this operation, and how it affects the NLL loss calculation.
Also, in your adversarial training, when you use policy gradient for the generator, you still add zeros, but this time, you only replace the first element of the data (which is called ‘input’ in your function) with zero. Could you please explain these for me?
Thankyou. looking forward to your reply.

how to decode

Are the data in the eval.data the index of some dictionaries like "Oxford University Press" or something like that?

Problem with running

Hi, thanks for the great code.

When I tried to run your vanilla example python main.py I got:

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

I'm running it under python 3.5.6 and pytorch 1.0.0

Bug on line 140 of main

arguments are incorrectly positioned. d_num_class is what you want to use for output dim ... I think, so you need to place that variable after num_filters and before dropout.

Right now you have it placed as the first input argument, which shifts all the following arguments into incorrect positions.

bug on 56 line of rollout.py

a subtle yet important mistake
the origin code:
'rewards[seq_len-1] += pred'
is likely to be changed as
'rewards[l-1] += pred'

loss.py

Hi, where is loss.py used?
I didn't see main.py import it .
you use nn.NLLLoss as loss function but loss.NLLLoss
thanks

in GAN training, rewards do not get reshaped correctly unless using cuda

rewards = rollout.get_reward(samples, 16, discriminator) rewards = Variable(torch.Tensor(rewards)) if args.cuda: rewards = torch.exp(rewards.cuda()).contiguous().view((-1,))
This is around lines 214-218, though maybe slightly different for you since I have edited the code.
I'm pretty sure that the reshaping of the rewards variable needs to happen regardless of whether or not cuda is being used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.