Autograd Utility: Gradcheck

Autograd Utility: Gradcheck#

Collection of utility functions for testing.

tad_mctc.autograd.gradcheck.dgradcheck(func, diffvars, **kwargs)[source]#

Wrapper for torch.autograd.gradcheck that detaches the differentiated variables after the check.

Parameters:
  • func (Callable[…, TensorOrTensors]) – Forward function.

  • diffvars (TensorOrTensors) – Variables w.r.t. which we differentiate.

Returns:

Status of check.

Return type:

bool

tad_mctc.autograd.gradcheck.dgradgradcheck(func, diffvars, **kwargs)[source]#

Wrapper for torch.autograd.gradgradcheck that detaches the differentiated variables after the check.

Parameters:
  • func (Callable[…, TensorOrTensors]) – Forward function.

  • diffvars (TensorOrTensors) – Variables w.r.t. which we differentiate.

Returns:

Status of check.

Return type:

bool