zhiqiangdon / online-augment

Code for "OnlineAugment: Online Data Augmentation with Less Domain Knowledge" (ECCV 2020)
Apache License 2.0
37 stars 4 forks source link

Question about the loss calculation #2

Open RizhaoCai opened 3 years ago

RizhaoCai commented 3 years ago

Hi,

Thanks for contributing the source code. I have some questions about the loss calculation in https://github.com/zhiqiangdon/online-augment/blob/9d46ab4789f6cd91b84fd05445866f3b3927e94f/train_aug_stn.py#L154

image According to the paper, for training the augmentation network, the adversarial losses has a minus sign ahead. image

Why in the code, Line 160 is commented? image And why Line 163 is not loss_aug_net = -1*loss_aug + loss_div + loss_diversity

StevenLauHKHK commented 2 years ago

Hi,

Thanks for contributing the source code. I have some questions about the loss calculation in

https://github.com/zhiqiangdon/online-augment/blob/9d46ab4789f6cd91b84fd05445866f3b3927e94f/train_aug_stn.py#L154

image According to the paper, for training the augmentation network, the adversarial losses has a minus sign ahead. image

Why in the code, Line 160 is commented? image And why Line 163 is not loss_aug_net = -1*loss_aug + loss_div + loss_diversity

Hi RizhaoCai. Recently, I tried to run the source code and repeat the experiment. I have the same question as yours. Do you have any insight why it uses the input_aug.register_hook(lambda grad: grad (-model.args.adv_weight_stn)) but not loss_aug_net = -1loss_aug + loss_div + loss_diversity?

zhiqiangdon commented 2 years ago

Hi @RizhaoCai and @StevenLauHKHK,

Thanks for your interest.

The implementation is to make training efficient. By using the hooker to reverse gradient before flowing from the target network to augmentation network, the two networks can be updated in one forward and backward.