sakura.utils.gradient_reverse.ReverseLayerF

class sakura.utils.gradient_reverse.ReverseLayerF(*args, **kwargs)

Bases: Function

Custom autograd class that reverses and scales gradients during backward pass

During forward:
  • Acts as identity operation (returns input unchanged)

During backward:
  • Reverses gradient direction by multiplying with negative alpha;

  • Scales gradients by alpha coefficient

Methods

backward

Backward pass for the custom autograd operation with gradient scaling.

forward

Forward pass for a custom autograd operation with gradient scaling.

Attributes