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

About the first-order approximation #6

Open
tht106 opened this issue Dec 31, 2020 · 2 comments
Open

About the first-order approximation #6

tht106 opened this issue Dec 31, 2020 · 2 comments

Comments

@tht106
Copy link

tht106 commented Dec 31, 2020

Hi, thank you for this fascinating work and providing a demo of MLDG.

Two quick questions:

  1. Did you use the first-order approximation in the MLP version of MLDG. The codes in ops.py look like an operation of the first-order approximation.

`

    if not stop_gradient:
        grad_weight = autograd.grad(meta_loss, weight, create_graph=True)[0]

        if bias is not None:
            grad_bias = autograd.grad(meta_loss, bias, create_graph=True)[0]
            bias_adapt = bias - grad_bias * meta_step_size
        else:
            bias_adapt = bias

    else:
        grad_weight = Variable(autograd.grad(meta_loss, weight, create_graph=True)[0].data, requires_grad=False)

        if bias is not None:
            grad_bias = Variable(autograd.grad(meta_loss, bias, create_graph=True)[0].data, requires_grad=False)
            bias_adapt = bias - grad_bias * meta_step_size
        else:
            bias_adapt = bias

    return F.linear(inputs,
                    weight - grad_weight * meta_step_size,
                    bias_adapt)
else:
    return F.linear(inputs, weight, bias)`
  1. I am also wondering the meaning of the parameter "--stop_gradient". What would happen when we set it ture?
@CinKKKyo
Copy link

Hi, thank you for this fascinating work and providing a demo of MLDG.

Two quick questions:

  1. Did you use the first-order approximation in the MLP version of MLDG. The codes in ops.py look like an operation of the first-order approximation.

`

    if not stop_gradient:
        grad_weight = autograd.grad(meta_loss, weight, create_graph=True)[0]

        if bias is not None:
            grad_bias = autograd.grad(meta_loss, bias, create_graph=True)[0]
            bias_adapt = bias - grad_bias * meta_step_size
        else:
            bias_adapt = bias

    else:
        grad_weight = Variable(autograd.grad(meta_loss, weight, create_graph=True)[0].data, requires_grad=False)

        if bias is not None:
            grad_bias = Variable(autograd.grad(meta_loss, bias, create_graph=True)[0].data, requires_grad=False)
            bias_adapt = bias - grad_bias * meta_step_size
        else:
            bias_adapt = bias

    return F.linear(inputs,
                    weight - grad_weight * meta_step_size,
                    bias_adapt)
else:
    return F.linear(inputs, weight, bias)`
  1. I am also wondering the meaning of the parameter "--stop_gradient". What would happen when we set it true?

The meaning of the parameter "--stop_gradient" also make me confused. Did you figure it out?

@CharmsGraker
Copy link

Hi, thank you for this fascinating work and providing a demo of MLDG.
Two quick questions:

  1. Did you use the first-order approximation in the MLP version of MLDG. The codes in ops.py look like an operation of the first-order approximation.

`

    if not stop_gradient:
        grad_weight = autograd.grad(meta_loss, weight, create_graph=True)[0]

        if bias is not None:
            grad_bias = autograd.grad(meta_loss, bias, create_graph=True)[0]
            bias_adapt = bias - grad_bias * meta_step_size
        else:
            bias_adapt = bias

    else:
        grad_weight = Variable(autograd.grad(meta_loss, weight, create_graph=True)[0].data, requires_grad=False)

        if bias is not None:
            grad_bias = Variable(autograd.grad(meta_loss, bias, create_graph=True)[0].data, requires_grad=False)
            bias_adapt = bias - grad_bias * meta_step_size
        else:
            bias_adapt = bias

    return F.linear(inputs,
                    weight - grad_weight * meta_step_size,
                    bias_adapt)
else:
    return F.linear(inputs, weight, bias)`
  1. I am also wondering the meaning of the parameter "--stop_gradient". What would happen when we set it true?

The meaning of the parameter "--stop_gradient" also make me confused. Did you figure it out?
setting stop_gradient=True is to avoid large budget when excuting meta-optimization.
In my opinion, if stop_gradient=True, the whole algorithm could be reckoned as training objections of F(theta), G(theta) alternatively.

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