1. Learn
  2. /
  3. Courses
  4. /
  5. Deep Reinforcement Learning in Python

Connected

Exercise

Working with discrete distributions

You are soon going to work with stochastic policies: policies which represent the agent's behavior in a given state as a probability distribution over actions.

PyTorch can represent discrete distributions using the torch.distributions.Categorical class, which you will now experiment with.

You will see that it is actually not necessary for the numbers used as input to sum to 1, as probabilities do; they get normalized automatically.

Instructions

100 XP
  • Instantiate the categorical probability distribution.
  • Take one sample from the distribution.
  • Specify 3 positive numbers summing to 1, to act as probabilities.
  • Specify 5 positive numbers; Categorical will silently normalize them to obtain probabilities.