MCPcopy Create free account
hub / github.com/pytorch/examples / select_action

Function select_action

reinforcement_learning/reinforce.py:54–60  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

52
53
54def select_action(state):
55 state = torch.from_numpy(state).float().unsqueeze(0)
56 probs = policy(state)
57 m = Categorical(probs)
58 action = m.sample()
59 policy.saved_log_probs.append(m.log_prob(action))
60 return action.item()
61
62
63def finish_episode():

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected