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 the loss calculation #2

Open
RizhaoCai opened this issue Mar 16, 2021 · 2 comments
Open

Question about the loss calculation #2

RizhaoCai opened this issue Mar 16, 2021 · 2 comments

Comments

@RizhaoCai
Copy link

RizhaoCai commented Mar 16, 2021

Hi,

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

loss_aug_net = loss_aug + loss_div + loss_diversity

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
Copy link

Hi,

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

loss_aug_net = loss_aug + loss_div + loss_diversity

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 = -1*loss_aug + loss_div + loss_diversity?

@zhiqiangdon
Copy link
Owner

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.

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

3 participants