ema-pytorch 0.3.0__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ema-pytorch might be problematic. Click here for more details.
- ema_pytorch/ema_pytorch.py +13 -3
- {ema_pytorch-0.3.0.dist-info → ema_pytorch-0.3.2.dist-info}/METADATA +1 -1
- ema_pytorch-0.3.2.dist-info/RECORD +7 -0
- {ema_pytorch-0.3.0.dist-info → ema_pytorch-0.3.2.dist-info}/WHEEL +1 -1
- ema_pytorch-0.3.0.dist-info/RECORD +0 -7
- {ema_pytorch-0.3.0.dist-info → ema_pytorch-0.3.2.dist-info}/LICENSE +0 -0
- {ema_pytorch-0.3.0.dist-info → ema_pytorch-0.3.2.dist-info}/top_level.txt +0 -0
ema_pytorch/ema_pytorch.py
CHANGED
|
@@ -43,7 +43,7 @@ class EMA(Module):
|
|
|
43
43
|
|
|
44
44
|
Args:
|
|
45
45
|
inv_gamma (float): Inverse multiplicative factor of EMA warmup. Default: 1.
|
|
46
|
-
power (float): Exponential factor of EMA warmup. Default:
|
|
46
|
+
power (float): Exponential factor of EMA warmup. Default: 2/3.
|
|
47
47
|
min_value (float): The minimum EMA decay rate. Default: 0.
|
|
48
48
|
"""
|
|
49
49
|
|
|
@@ -53,6 +53,7 @@ class EMA(Module):
|
|
|
53
53
|
model: Module,
|
|
54
54
|
ema_model: Optional[Module] = None, # if your model has lazylinears or other types of non-deepcopyable modules, you can pass in your own ema model
|
|
55
55
|
beta = 0.9999,
|
|
56
|
+
karras_beta = False, # if True, uses the karras time dependent beta
|
|
56
57
|
update_after_step = 100,
|
|
57
58
|
update_every = 10,
|
|
58
59
|
inv_gamma = 1.0,
|
|
@@ -65,7 +66,8 @@ class EMA(Module):
|
|
|
65
66
|
allow_different_devices = False # if the EMA model is on a different device (say CPU), automatically move the tensor
|
|
66
67
|
):
|
|
67
68
|
super().__init__()
|
|
68
|
-
self.
|
|
69
|
+
self._beta = beta
|
|
70
|
+
self.karras_beta = karras_beta
|
|
69
71
|
|
|
70
72
|
# whether to include the online model within the module tree, so that state_dict also saves it
|
|
71
73
|
|
|
@@ -83,7 +85,8 @@ class EMA(Module):
|
|
|
83
85
|
if not exists(self.ema_model):
|
|
84
86
|
try:
|
|
85
87
|
self.ema_model = deepcopy(model)
|
|
86
|
-
except:
|
|
88
|
+
except Exception as e:
|
|
89
|
+
print(f'Error: While trying to deepcopy model: {e}')
|
|
87
90
|
print('Your model was not copyable. Please make sure you are not using any LazyLinear')
|
|
88
91
|
exit()
|
|
89
92
|
|
|
@@ -126,6 +129,13 @@ class EMA(Module):
|
|
|
126
129
|
@property
|
|
127
130
|
def model(self):
|
|
128
131
|
return self.online_model if self.include_online_model else self.online_model[0]
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def beta(self):
|
|
135
|
+
if self.karras_beta:
|
|
136
|
+
return (1 - 1 / (self.step + 1)) ** (1 + self.power)
|
|
137
|
+
|
|
138
|
+
return self._beta
|
|
129
139
|
|
|
130
140
|
def eval(self):
|
|
131
141
|
return self.ema_model.eval()
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ema_pytorch/__init__.py,sha256=jCgUV6FfA65ct6lMEClKKwl-gjZMDv7aOeaN3RshE0U,40
|
|
2
|
+
ema_pytorch/ema_pytorch.py,sha256=WBOhcK_7WWBy48tYcsIJceaZvF4oz8qjOueQX1LoLqI,8489
|
|
3
|
+
ema_pytorch-0.3.2.dist-info/LICENSE,sha256=xZDkKtpHE2TPCAeqKe1fjdpKernl1YW-d01j_1ltkAU,1066
|
|
4
|
+
ema_pytorch-0.3.2.dist-info/METADATA,sha256=uVi-SjuBOrGBWKLct4GHX_0x16eeKVIp7795jRbaDp4,715
|
|
5
|
+
ema_pytorch-0.3.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
6
|
+
ema_pytorch-0.3.2.dist-info/top_level.txt,sha256=XXFJmHviark_32Hfm5X9niezVmnRTUIhfdifCrJgXmE,12
|
|
7
|
+
ema_pytorch-0.3.2.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
ema_pytorch/__init__.py,sha256=jCgUV6FfA65ct6lMEClKKwl-gjZMDv7aOeaN3RshE0U,40
|
|
2
|
-
ema_pytorch/ema_pytorch.py,sha256=4OPFewDiKVezIvEdvXvn4d4PGrXafhlH39qg_5lrMGk,8102
|
|
3
|
-
ema_pytorch-0.3.0.dist-info/LICENSE,sha256=xZDkKtpHE2TPCAeqKe1fjdpKernl1YW-d01j_1ltkAU,1066
|
|
4
|
-
ema_pytorch-0.3.0.dist-info/METADATA,sha256=uzoXWFnqKpq9tFZGU1oK1ZKJSEqZ_CFiMmAy2LLYt4A,715
|
|
5
|
-
ema_pytorch-0.3.0.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
|
6
|
-
ema_pytorch-0.3.0.dist-info/top_level.txt,sha256=XXFJmHviark_32Hfm5X9niezVmnRTUIhfdifCrJgXmE,12
|
|
7
|
-
ema_pytorch-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|