Created
May 24, 2020 22:32
-
-
Save elumixor/cec4d042835c969190929ca52ffddb0c to your computer and use it in GitHub Desktop.
TRPO Get Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from torch.distributions import Categorical | |
| def get_action(state): | |
| state = torch.tensor(state).float().unsqueeze(0) # Turn state into a batch with a single element | |
| dist = Categorical(actor(state)) # Create a distribution from probabilities for actions | |
| return dist.sample().item() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment