Skip to content

Commit 017bfba

Browse files
author
nighood
committed
polish(rjy): norm eval_episode_return
1 parent a9ebcfb commit 017bfba

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

dizoo/ising_env/envs/ising_model_env.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def reset(self) -> np.ndarray:
7272
obs = np.concatenate([obs, pre_action_prob], axis=1)
7373
obs = to_ndarray(obs).astype(np.float32)
7474
self._eval_episode_return = 0
75+
self.cur_step = 0
7576
return obs
7677

7778
def close(self) -> None:
@@ -97,10 +98,11 @@ def step(self, action: np.ndarray) -> BaseEnvTimestep:
9798
obs = to_ndarray(obs).astype(np.float32)
9899
rew = np.concatenate(rew)
99100
self._eval_episode_return += np.sum(rew)
101+
self.cur_step += 1
100102

101103
done = done[0] # dones are the same for all agents
102104
if done:
103-
info['eval_episode_return'] = self._eval_episode_return
105+
info['eval_episode_return'] = self._eval_episode_return / self.cur_step
104106
return BaseEnvTimestep(obs, rew, done, info)
105107

106108
def random_action(self) -> np.ndarray:

0 commit comments

Comments
 (0)