GradReverse
Bases: Function
Gradient Reversal Layer for adversarial training.
Implements a custom autograd function that:
- Forward: Identity operation
- Backward: Reverses and scales gradients
backward(ctx, grad_output)
staticmethod
Backward pass of gradient reversal.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Implements gradient reversal: grad = -alpha * grad_output
forward(ctx, x, alpha)
staticmethod
Forward pass of gradient reversal.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Identity operation in forward pass, stores alpha for backward.