WganGpFusedStep<T>
Models & Types · AiDotNet.Training
Fused WGAN-GP critic training step (Gulrajani et al. 2017). Runs the
combined E[D(fake)] − E[D(real)] + λ·(‖∇_x̃ D(x̃)‖₂ − 1)² objective
through the compiled fused plan, where the gradient-penalty term’s inner
backward is expressed as a nested-tape computation.
Fused benefit: the outer forward + backward + optimizer step
are captured in ONE compiled plan. The inner ∇_x̃ D(x̃) gradient is captured
on the outer tape via createGraph=true — this is why the compiled
backward’s createGraph=true support (Phase 4C on the engine side)
is a prerequisite. The plan replays with fresh real/fake batches per step.
Correctness contract: the inner gradient’s ops are recorded on the outer tape so the outer backward can differentiate the penalty into disc weights (which the pre-fix AiDotNet code failed to do — see issue #1844). This class’s structure enforces the createGraph=true call on the inner tape.
Implements: IDisposable
Constructors
| Constructor | Summary |
|---|---|
WganGpFusedStep() |
Properties
| Property | Summary |
|---|---|
bool IsAvailable { get; } |
Methods
| Method | Summary |
|---|---|
bool TryStep(IReadOnlyList<Tensor<T>> discParameters, Tensor<T> realBatch, Tensor<T> fakeBatch, Func<Tensor<T>, Tensor<T>> discForward, Func<int, Tensor<T>> epsilonSampler, double gradientPenaltyWeight, OptimizerType optimizerType, double learningRate, double beta1, double beta2, double epsilon, double weightDecay, LrSchedule lrSchedule, FusedOptimizerExtras extras, T lossValue) |
The same step with the optimizer’s fused LR schedule and kernel extras. |
bool TryStep(IReadOnlyList<Tensor<T>> discParameters, Tensor<T> realBatch, Tensor<T> fakeBatch, Func<Tensor<T>, Tensor<T>> discForward, Func<int, Tensor<T>> epsilonSampler, double gradientPenaltyWeight, OptimizerType optimizerType, double learningRate, double beta1, double beta2, double epsilon, double weightDecay, T lossValue) |
Runs one WGAN-GP critic step with fresh real + fake batches. |
void Dispose() |
|
void Invalidate() |