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

Function compute_jac

intermediate_source/jacobians_hessians.py:49–52  ·  view source on GitHub ↗
(xp)

Source from the content-addressed store, hash-verified

47# by using a different unit vector each time.
48
49def compute_jac(xp):
50 jacobian_rows = [torch.autograd.grad(predict(weight, bias, xp), xp, vec)[0]
51 for vec in unit_vectors]
52 return torch.stack(jacobian_rows)
53
54xp = x.clone().requires_grad_()
55unit_vectors = torch.eye(D)

Callers 1

Calls 1

predictFunction · 0.85

Tested by

no test coverage detected