advertorch.bpda

BPDA

BPDAWrapper Backward Pass Differentiable Approximation.

Detailed description

class advertorch.bpda.BPDAWrapper(forward, forwardsub=None, backward=None)[source]

Backward Pass Differentiable Approximation.

The module should be provided a forward method and a backward method that approximates the derivatives of forward.

The forward function is called in the forward pass, and the backward function is used to find gradients in the backward pass.

The backward function can be implicitly provided-by providing forwardsub - an alternative forward pass function, which its gradient will be used in the backward pass.

If not backward nor forwardsub are provided, the backward function will be assumed to be the identity.

Parameters:
  • forwardforward(*inputs) - the forward function for BPDA.
  • forwardsub – (Optional) a substitute forward function, for the gradients approximation of forward.
  • backward – (Optional) backward(inputs, grad_outputs) the backward pass function for BPDA.