From eb78b3bf8cf5a2f26d621978681ac4782487411d Mon Sep 17 00:00:00 2001 From: megemini Date: Sat, 6 Jul 2024 18:09:01 +0800 Subject: [PATCH] [Add] typing --- python/paddle/distribution/exponential_family.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/paddle/distribution/exponential_family.py b/python/paddle/distribution/exponential_family.py index 2e668501acdab..72410c1c90211 100644 --- a/python/paddle/distribution/exponential_family.py +++ b/python/paddle/distribution/exponential_family.py @@ -12,10 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import annotations + +from typing import TYPE_CHECKING + import paddle from paddle.distribution import distribution from paddle.framework import in_dynamic_mode +if TYPE_CHECKING: + from paddle import Tensor + class ExponentialFamily(distribution.Distribution): r""" @@ -47,7 +54,7 @@ def _log_normalizer(self): def _mean_carrier_measure(self): raise NotImplementedError - def entropy(self): + def entropy(self) -> Tensor: """calculate entropy use `bregman divergence` https://www.lix.polytechnique.fr/~nielsen/EntropyEF-ICIP2010.pdf """