Commit f74108c
committed
fix: return mu (not mu+std) in reparameterize at eval time
In VarAutoEncoder and VarFullyConnectedNet, the reparameterize method
computed and always returned .
At training time, was correctly replaced with random noise scaled
by the standard deviation. But at eval time, the raw standard deviation
was still added to the mean — giving instead of just .
The reparameterization trick (Kingma & Welling, 2014) defines:
- Training: z = μ + ε · σ (ε ~ N(0,1))
- Inference: z = μ (no stochastic component)
This fix restructures the method to return directly when not
training, avoiding the unnecessary computation
and eliminating the incorrect result at inference.
Fixes #8413
Signed-off-by: Raphael Malikian <rtmalikian@gmail.com>1 parent 15f5073 commit f74108c
2 files changed
Lines changed: 8 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
176 | 178 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 179 | + | |
181 | 180 | | |
182 | 181 | | |
183 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
146 | 148 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 149 | + | |
151 | 150 | | |
152 | 151 | | |
153 | 152 | | |
| |||
0 commit comments