MCPcopy Create free account
hub / github.com/CompVis/zigma / ema

Function ema

utils/train_state_utils.py:13–18  ·  view source on GitHub ↗
(model_dest: nn.Module, model_src: nn.Module, rate)

Source from the content-addressed store, hash-verified

11
12
13def ema(model_dest: nn.Module, model_src: nn.Module, rate):
14 param_dict_src = dict(model_src.named_parameters())
15 for p_name, p_dest in model_dest.named_parameters():
16 p_src = param_dict_src[p_name]
17 assert p_src is not p_dest
18 p_dest.data.mul_(rate).add_((1 - rate) * p_src.data)
19
20
21class TrainState(object):

Callers 1

ema_updateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected