MCPcopy
hub / github.com/meta-pytorch/captum / test_gradient_inplace

Method test_gradient_inplace

tests/utils/test_gradient.py:156–160  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

154 )
155
156 def test_gradient_inplace(self) -> None:
157 model = BasicModel_MultiLayer(inplace=True)
158 input = torch.tensor([[1.0, 6.0, -3.0]], requires_grad=True)
159 grads = compute_gradients(model, input, target_ind=0)[0]
160 assertTensorAlmostEqual(self, grads, [[3.0, 3.0, 3.0]], delta=0.01, mode="max")
161
162 def test_layer_gradient_linear0(self) -> None:
163 model = BasicModel_MultiLayer()

Callers

nothing calls this directly

Calls 3

compute_gradientsFunction · 0.90
assertTensorAlmostEqualFunction · 0.90

Tested by

no test coverage detected