Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about seqgan rollout code #62

Open
dldaisy opened this issue Jan 5, 2022 · 0 comments
Open

question about seqgan rollout code #62

dldaisy opened this issue Jan 5, 2022 · 0 comments

Comments

@dldaisy
Copy link

dldaisy commented Jan 5, 2022

Hi @williamSYSU,
Thanks for the work.
I found a potential bug in your seqgan rollout code.
In the below code snippet in function get_reward in utils/rollout.py,

rewards = torch.zeros([rollout_num * self.max_seq_len, batch_size]).float()
......
rewards = torch.mean(rewards.view(batch_size, self.max_seq_len, rollout_num), dim=-1)

the reward tensor is reshaped from [rollout_num, max_seq_len, batch_size] to [batch_size, max_seq_len, rollout_num] and then (is expected to be) reduced at rollout_num. However, the tensor would have a different layout after the view as expected, which means the reduce would be performed erroneously.
To correct this error, I think there needs to be a transpose operation before view.
Looking forward to your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant