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

Method ema_scope

sat/vae_modules/autoencoder.py:98–110  ·  view source on GitHub ↗
(self, context=None)

Source from the content-addressed store, hash-verified

96
97 @contextmanager
98 def ema_scope(self, context=None):
99 if self.use_ema:
100 self.model_ema.store(self.parameters())
101 self.model_ema.copy_to(self)
102 if context is not None:
103 logpy.info(f"{context}: Switched to EMA weights")
104 try:
105 yield None
106 finally:
107 if self.use_ema:
108 self.model_ema.restore(self.parameters())
109 if context is not None:
110 logpy.info(f"{context}: Restored training weights")
111
112 @abstractmethod
113 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