Skip to content

Can compute_grad1 support multiple backprops? #6

@zhangxz1123

Description

@zhangxz1123

Hi Yaroslav,
First of all, I want to say your tricks here are really neat and have helped me a lot!

I'm currently trying to compute the per-example gradient over two backprops in a typical Hessian vector product calculation, e.g.

output = model(data)
loss = loss_fn(output, targets)
grad = torch.autograd.grad(loss, model.parameters(), create_graph=True)
grad = flat_grad(grad)
grad_p = (grad * p).sum()
hessian_p= torch.autograd.grad(grad_p , actor.parameters())

Is it possible to apply compute_grad1 to this procedure to get the per-example Hessian vector product? Naively applying it fails because currently compute_grad1 only supports a single backprop.

Thanks!
Jack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions