Skip to content

Commit

Permalink
fix v dtype in ema black list (#8466)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyuwenyu authored Jul 25, 2023
1 parent 9ed7ad2 commit 47d7ee5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ppdet/optimizer/ema.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self,
self.state_dict = dict()
for k, v in model.state_dict().items():
if k in self.ema_black_list:
self.state_dict[k] = v.astype('float32')
self.state_dict[k] = v
else:
self.state_dict[k] = paddle.zeros_like(v, dtype='float32')

Expand Down Expand Up @@ -127,7 +127,7 @@ def apply(self):
for k, v in self.state_dict.items():
if k in self.ema_black_list:
v.stop_gradient = True
state_dict[k] = v.astype(model_dict[k].dtype)
state_dict[k] = v
else:
if self.ema_decay_type != 'exponential':
v = v / (1 - self._decay**self.step)
Expand Down

0 comments on commit 47d7ee5

Please sign in to comment.