Apply adversarial training after few epochs.
jhss opened this issue · 2 comments
I want to train the model without adversarial attack at the first two epochs.
After that, I would like to train the model with adversarial learning.
In summary,
1 epoch: Training w/o adversarial
2 epoch: Training w/o adversarial
3 epoch: Training with adversarial
4 epoch: Training with adversarial
....
Is it possible to adjust the start epoch of the adversarial training?
I couldn't find any related parameter in nsl.configs.make_adv_reg_config
Hi @jhss, thanks for the question.
You're right that make_adv_reg_config doesn't have such parameter for delaying the adversarial training. Instead, you may train a base model for a few epochs before wrapping it with nsl.keras.AdversarialRegularization. This achieves the desired behavior because an AdversarialRegularization-wrapped model and its base model share the model variables. The following code snippet illustrates this idea:
base_model.fit(training_data, epochs=num_epochs_without_adv_training)
adv_model = nsl.keras.AdversarialRegularization(base_model, ...)
adv_model.fit(training_data, epochs=num_epochs_with_adv_training))Closing this issue due to inactivity in 30 days. Please feel free to reopen if you have more questions.