Skip to content

Commit 1abbfce

Browse files
authored
Merge pull request #27 from wniec/update-normalize-order-of-updates
fix: update after normalization
2 parents 1396a48 + ef76f1a commit 1abbfce

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

dynamicalgorithmselection/agents/agent_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ def __init__(self, max_steps, clip_reward=10.0):
135135

136136
def normalize(self, reward, step_idx, update=True):
137137
idx = min(step_idx, self.max_steps - 1)
138-
if update:
139-
self.stats[idx].update(np.array([reward]))
140138

141139
mean = self.stats[idx].mean
142140
std = np.sqrt(self.stats[idx].var) + 1e-8
143-
144141
normalized_reward = (reward - mean) / std
145142

143+
if update:
144+
self.stats[idx].update(np.array([reward]))
145+
146146
return np.clip(normalized_reward, -self.clip, self.clip)

0 commit comments

Comments
 (0)