fix: add missing style_encoder optimizer step in reference-guided training#181
Open
Mukller wants to merge 1 commit into
Open
fix: add missing style_encoder optimizer step in reference-guided training#181Mukller wants to merge 1 commit into
Mukller wants to merge 1 commit into
Conversation
Mukller
commented
Jul 10, 2026
Mukller
left a comment
Author
There was a problem hiding this comment.
Code Review: fix missing style_encoder optimizer step in reference-guided training
Summary
Adds the missing optims.style_encoder.step() call in the reference-guided training branch. Without it, the style encoder's parameters would not be updated during gradient descent, causing the style encoder to remain frozen while the generator trains against it — leading to suboptimal style transfer quality and silent incorrect behavior.
Critical Issues
| # | File | Line | Issue | Severity |
|---|---|---|---|---|
| 1 | core/solver.py |
~135 | optims.style_encoder.step() was missing after g_loss.backward(), leaving the style encoder's weights frozen during reference-guided training |
🔴 Critical |
What the Fix Does
# Before (bug) — style encoder never updated
self._reset_grad()
g_loss.backward()
optims.generator.step()
# ← style encoder step missing
# After (correct)
self._reset_grad()
g_loss.backward()
optims.generator.step()
optims.style_encoder.step() # ← style encoder now correctly updatedWhat Looks Good
- Single-line addition, no side effects
- Consistent with the latent-guided training path, which correctly updates both generator and mapping network
Verdict
Request Changes → now fixed. This is a silent training bug: no crash, no obvious error, but the style encoder would not learn during reference-guided training, producing degraded results.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Fix: Style encoder not updated during reference-guided generator training
During the training loop, the style encoder optimizer step is called after
latent-guided generator training but is missing from reference-guided training.
This means the style encoder never learns from reference images during the
alternating training procedure, which contradicts the StarGAN v2 training algorithm.
Before (missing style_encoder.step for ref-guided training):
After (fixed):
Closes #179