MCPcopy Create free account
hub / github.com/pytorch/tutorials / get_vjp

Function get_vjp

unstable_source/vmap_recipe.py:99–100  ·  view source on GitHub ↗
(v)

Source from the content-addressed store, hash-verified

97# Using `vmap`, we can vectorize the whole computation, computing the
98# Jacobian in a single call to `autograd.grad`.
99def get_vjp(v):
100 return torch.autograd.grad(y, x, v)[0]
101
102jacobian_vmap = vmap(get_vjp)(basis_vectors)
103assert torch.allclose(jacobian_vmap, jacobian)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected