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

back-propagate the discriminator loss through the generator #8

Closed
mehdimashayekhi opened this issue Nov 22, 2020 · 1 comment
Closed

Comments

@mehdimashayekhi
Copy link

Hi , Thanks for sharing your code. I have a quick question, in the paper it is mentioned that We don’t back-propagate the discriminator loss through the generator, maybe I have missed it, but where in your code this has been taken care of ? can you refer me to it ? Thanks

@richarddwang
Copy link
Owner

Hi.
There is a sampling between generator and discriminator and sampling is not able to be backward propagated.

electra_pytorch/pretrain.py

Lines 294 to 302 in 9b2533e

with torch.no_grad():
# sampling
pred_toks = self.sample(mlm_gen_logits) # ( #mlm_positions, )
# produce inputs for discriminator
generated = masked_inputs.clone() # (B,L)
generated[is_mlm_applied] = pred_toks # (B,L)
# produce labels for discriminator
is_replaced = is_mlm_applied.clone() # (B,L)
is_replaced[is_mlm_applied] = (pred_toks != labels[is_mlm_applied]) # (B,L)

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

2 participants