MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / ema_scope

Method ema_scope

sat/sgm/models/autoencoder.py:82–94  ·  view source on GitHub ↗
(self, context=None)

Source from the content-addressed store, hash-verified

80
81 @contextmanager
82 def ema_scope(self, context=None):
83 if self.use_ema:
84 self.model_ema.store(self.parameters())
85 self.model_ema.copy_to(self)
86 if context is not None:
87 logpy.info(f"{context}: Switched to EMA weights")
88 try:
89 yield None
90 finally:
91 if self.use_ema:
92 self.model_ema.restore(self.parameters())
93 if context is not None:
94 logpy.info(f"{context}: Restored training weights")
95
96 @abstractmethod
97 def encode(self, *args, **kwargs) -> torch.Tensor:

Callers 2

validation_stepMethod · 0.45
log_imagesMethod · 0.45

Calls 4

parametersMethod · 0.80
storeMethod · 0.45
copy_toMethod · 0.45
restoreMethod · 0.45

Tested by

no test coverage detected