-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
add categorical class #27695
add categorical class #27695
Conversation
Thanks for your contribution! |
* :math:`[x=i]` : it evaluates to 1 if :math:`x==i` , 0 otherwise. | ||
|
||
Args: | ||
logits(list|numpy.ndarray|Tensor): The logits input of categorical distribution. The data type is float32 or float64. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add parameter name
, will refine it in next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, refer to PR #27946
def __init__(self, logits, name=None): | ||
""" | ||
Args: | ||
logits(list|numpy.ndarray|Variable): The logits input of categorical distribution. The data type is float32 or float64. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable
change to Tensor
, add parameter name
, will refine it in next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, refer to PR #27946
other (Categorical): instance of Categorical. The data type is float32. | ||
|
||
Returns: | ||
Variable: kl-divergence between two Categorical distributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change Variable
to Tensor
, will refine it in next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, refer to PR #27946
"""Shannon entropy in nats. | ||
|
||
Returns: | ||
Variable: Shannon entropy of Categorical distribution. The data type is float32. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change Variable
to Tensor
, will refine it in next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, refer to PR #27946
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Tensor: A tensor with prepended dimensions shape. | ||
|
||
Examples: | ||
.. code-block:: python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``code-block:: python` needs indentation. The same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, refer to PR #27946
PR types
Others
PR changes
APIs
Describe
add
Categorical
classIt's a special case of
multinomial
( refer to PR add multinomial op #27219 ).Categorical
distribution is a discrete probability distribution that describes the possible results of a random variable that can take on one of K possible categories, with the probability of each category separately specified.add
sample
methodUsing
multinomial
to sample fromCategorical
distribution.add
probs
andlog_prob
methodGiven category index, return the probability of this category.