Skip to content

Commit

Permalink
Merge pull request #359 from stellawang196/master
Browse files Browse the repository at this point in the history
Fix issue 354
  • Loading branch information
zhumingpassional committed Jun 5, 2024
2 parents 155f07f + ab1fa91 commit 5ef11a5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions elegantrl/train/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def get_cumulative_rewards_and_steps(env, actor, if_render: bool = False) -> Tup
tensor_state = torch.as_tensor(state, dtype=torch.float32, device=device).unsqueeze(0)
tensor_action = actor(tensor_state)
if if_discrete:
if tensor_action.dim() == 1:
tensor_action = tensor_action.unsqueeze(0)
tensor_action = tensor_action.argmax(dim=1)
action = tensor_action.detach().cpu().numpy()[0] # not need detach(), because using torch.no_grad() outside
state, reward, done, _ = env.step(action)
Expand Down

0 comments on commit 5ef11a5

Please sign in to comment.