If there is no KL method registered specifically for type(distribution_a)
and type(distribution_b), then the class hierarchies of these types are
searched.
If one KL method is registered between any pairs of classes in these two
parent hierarchies, it is used.
If more than one such registered method exists, the method whose registered
classes have the shortest sum MRO paths to the input types is used.
If more than one such shortest path exists, the first method
identified in the search is used (favoring a shorter MRO distance to
type(distribution_a)).
Args
distribution_a
The first distribution.
distribution_b
The second distribution.
allow_nan_stats
Python bool, default True. When True,
statistics (e.g., mean, mode, variance) use the value "NaN" to
indicate the result is undefined. When False, an exception is raised
if one or more of the statistic's batch members are undefined.
name
Python str name prefixed to Ops created by this class.
Returns
A Tensor with the batchwise KL-divergence between distribution_a
and distribution_b.
Raises
NotImplementedError
If no KL method is defined for distribution types
of distribution_a and distribution_b.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.compat.v1.distributions.kl_divergence\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/distributions/kullback_leibler.py#L51-L118) |\n\nGet the KL-divergence KL(distribution_a \\|\\| distribution_b). (deprecated) \n\n tf.compat.v1.distributions.kl_divergence(\n distribution_a, distribution_b, allow_nan_stats=True, name=None\n )\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed after 2019-01-01. Instructions for updating: The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use [`tfp.distributions`](https://www.tensorflow.org/probability/api_docs/python/tfp/distributions) instead of `tf.distributions`.\n\nIf there is no KL method registered specifically for `type(distribution_a)`\nand `type(distribution_b)`, then the class hierarchies of these types are\nsearched.\n\nIf one KL method is registered between any pairs of classes in these two\nparent hierarchies, it is used.\n\nIf more than one such registered method exists, the method whose registered\nclasses have the shortest sum MRO paths to the input types is used.\n\nIf more than one such shortest path exists, the first method\nidentified in the search is used (favoring a shorter MRO distance to\n`type(distribution_a)`).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `distribution_a` | The first distribution. |\n| `distribution_b` | The second distribution. |\n| `allow_nan_stats` | Python `bool`, default `True`. When `True`, statistics (e.g., mean, mode, variance) use the value \"`NaN`\" to indicate the result is undefined. When `False`, an exception is raised if one or more of the statistic's batch members are undefined. |\n| `name` | Python `str` name prefixed to Ops created by this class. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A Tensor with the batchwise KL-divergence between `distribution_a` and `distribution_b`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-----------------------|---------------------------------------------------------------------------------------------|\n| `NotImplementedError` | If no KL method is defined for distribution types of `distribution_a` and `distribution_b`. |\n\n\u003cbr /\u003e"]]