Skip to content

An attempt at replicating the Fast Gradient Method(FGM) of adversarial training for NLP in paddle.

Notifications You must be signed in to change notification settings

wuzhiye7/paddle_adversarial_training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Adversarial Training for NLP in Paddle

An attempt at replicating the Fast Gradient Method(FGM) of adversarial training for NLP in paddle.

Usage Example

from FastGradientMethod import FGM
...

fgm = FGM(model)
for batch_input, batch_label in data:
     loss = model(batch_input, batch_label)
     loss.backward()
     fgm.attack()
     loss_adv = model(batch_input, batch_label)
     loss_adv.backward()
     fgm.restore() 
     optimizer.step()
     lr_scheduler.step()
     optimizer.clear_gradients()

Reference

https://fyubang.com/2019/10/15/adversarial-train/

About

An attempt at replicating the Fast Gradient Method(FGM) of adversarial training for NLP in paddle.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages