Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed deprecated tf.multinomial to tf.random.categorical at Part 1 #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/spinningup/rl_intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ In what follows, we'll describe how to do these for both categorical and diagona

A categorical policy is like a classifier over discrete actions. You build the neural network for a categorical policy the same way you would for a classifier: the input is the observation, followed by some number of layers (possibly convolutional or densely-connected, depending on the kind of input), and then you have one final linear layer that gives you logits for each action, followed by a `softmax`_ to convert the logits into probabilities.

**Sampling.** Given the probabilities for each action, frameworks like PyTorch and Tensorflow have built-in tools for sampling. For example, see the documentation for `Categorical distributions in PyTorch`_, `torch.multinomial`_, `tf.distributions.Categorical`_, or `tf.multinomial`_.
**Sampling.** Given the probabilities for each action, frameworks like PyTorch and Tensorflow have built-in tools for sampling. For example, see the documentation for `Categorical distributions in PyTorch`_, `torch.multinomial`_, `tf.distributions.Categorical`_, or `tf.random.categorical`_.

**Log-Likelihood.** Denote the last layer of probabilities as :math:`P_{\theta}(s)`. It is a vector with however many entries as there are actions, so we can treat the actions as indices for the vector. The log likelihood for an action :math:`a` can then be obtained by indexing into the vector:

Expand Down Expand Up @@ -207,7 +207,7 @@ In what follows, we'll describe how to do these for both categorical and diagona
.. _`Categorical distributions in PyTorch`: https://pytorch.org/docs/stable/distributions.html#categorical
.. _`torch.multinomial`: https://pytorch.org/docs/stable/torch.html#torch.multinomial
.. _`tf.distributions.Categorical`: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/distributions/Categorical
.. _`tf.multinomial`: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/random/multinomial
.. _`tf.random.categorical`: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/random/categorical
.. _`torch.normal`: https://pytorch.org/docs/stable/torch.html#torch.normal
.. _`tf.random_normal`: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/random/normal
.. _`torch.distributions.Normal`: https://pytorch.org/docs/stable/distributions.html#normal
Expand Down