Fix FiLM temporal context gradient leak: detach EMA to prevent cross-step backprop
Browse files
vil_tracker/models/film_temporal.py
CHANGED
|
@@ -143,10 +143,10 @@ class TemporalModulationManager(nn.Module):
|
|
| 143 |
"""
|
| 144 |
context = self.context_proj(features.detach())
|
| 145 |
if self._temporal_context is None:
|
| 146 |
-
self._temporal_context = context
|
| 147 |
else:
|
| 148 |
-
# EMA update
|
| 149 |
-
self._temporal_context = 0.7 * self._temporal_context + 0.3 * context
|
| 150 |
|
| 151 |
def modulate(
|
| 152 |
self,
|
|
|
|
| 143 |
"""
|
| 144 |
context = self.context_proj(features.detach())
|
| 145 |
if self._temporal_context is None:
|
| 146 |
+
self._temporal_context = context.detach()
|
| 147 |
else:
|
| 148 |
+
# EMA update — detach to prevent cross-step gradient leakage
|
| 149 |
+
self._temporal_context = (0.7 * self._temporal_context + 0.3 * context).detach()
|
| 150 |
|
| 151 |
def modulate(
|
| 152 |
self,
|