MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _grad

Function _grad

tensorflow/python/eager/forwardprop_test.py:80–92  ·  view source on GitHub ↗

Return a function which computes the gradient of `f`.

(f, argnums=0)

Source from the content-addressed store, hash-verified

78
79
80def _grad(f, argnums=0):
81 """Return a function which computes the gradient of `f`."""
82
83 def _f(*params):
84 with backprop.GradientTape() as tape:
85 tape.watch(params)
86 primals_out = f(*params)
87 return tape.gradient(
88 primals_out,
89 params[argnums],
90 unconnected_gradients=UnconnectedGradients.ZERO)
91
92 return _f
93
94
95def _hvp(f, primals, tangents):

Callers 4

_hvpFunction · 0.70
_test_gradientsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected