MCPcopy Index your code
hub / github.com/rlcode/reinforcement-learning / policy_action

Function policy_action

3-atari/2-ppo.py:82–86  ·  view source on GitHub ↗
(obs)

Source from the content-addressed store, hash-verified

80 model = ActorCritic(n_actions).to(device)
81 model.load_state_dict(torch.load(SAVE_PATH, map_location=device))
82 def policy_action(obs):
83 with torch.no_grad():
84 t = torch.as_tensor(np.asarray(obs), device=device).unsqueeze(0)
85 logits, _ = model(t)
86 return int(torch.distributions.Categorical(logits=logits).sample().item())
87 run_test_loop(env, policy_action)
88
89 envs = make_vec_env(args, N_ENVS)

Callers

nothing calls this directly

Calls 1

sampleMethod · 0.45

Tested by

no test coverage detected