Skip to content

Commit

Permalink
Fix some typos (distribuion, funciotn, etc.) (PaddlePaddle#62000)
Browse files Browse the repository at this point in the history
  • Loading branch information
co63oc committed Feb 26, 2024
1 parent 255478f commit 9d1196c
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion python/paddle/distribution/binomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _check_constraint(self, total_count, probs):

@property
def mean(self):
"""Mean of binomial distribuion.
"""Mean of binomial distribution.
Returns:
Tensor: mean value.
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/distribution/continuous_bernoulli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def _log_constant(self):

@property
def mean(self):
"""Mean of Continuous Bernoulli distribuion.
"""Mean of Continuous Bernoulli distribution.
Returns:
Tensor: mean value.
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/distribution/dirichlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Dirichlet(exponential_family.ExponentialFamily):
distribution, also called :math:`\alpha`. When it's over one
dimension, the last axis denotes the parameter of distribution,
``event_shape=concentration.shape[-1:]`` , axes other than last are
condsider batch dimensions with ``batch_shape=concentration.shape[:-1]`` .
consider batch dimensions with ``batch_shape=concentration.shape[:-1]`` .
Examples:
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(self, concentration):

@property
def mean(self):
"""Mean of Dirichelt distribution.
"""Mean of Dirichlet distribution.
Returns:
Mean value of distribution.
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/distribution/exponential.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, rate):

@property
def mean(self):
"""Mean of exponential distribuion.
"""Mean of exponential distribution.
Returns:
Tensor: mean value.
Expand Down Expand Up @@ -134,7 +134,7 @@ def rsample(self, shape=()):
return -paddle.log(uniform) / self.rate

def prob(self, value):
r"""Probability density funciotn evaluated at value.
r"""Probability density function evaluated at value.
.. math::
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/distribution/exponential_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _mean_carrier_measure(self):
raise NotImplementedError

def entropy(self):
"""caculate entropy use `bregman divergence`
"""calculate entropy use `bregman divergence`
https://www.lix.polytechnique.fr/~nielsen/EntropyEF-ICIP2010.pdf
"""
entropy_value = -self._mean_carrier_measure
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/distribution/gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self, concentration, rate):

@property
def mean(self):
"""Mean of gamma distribuion.
"""Mean of gamma distribution.
Returns:
Tensor: mean value.
Expand All @@ -130,7 +130,7 @@ def variance(self):
return self.concentration / self.rate.pow(2)

def prob(self, value):
"""Probability density funciotn evaluated at value
"""Probability density function evaluated at value
Args:
value (float|Tensor): Value to be evaluated.
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/distribution/geometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def stddev(self):
return paddle.sqrt(self.variance)

def pmf(self, k):
r"""Probability mass funciotn evaluated at k.
r"""Probability mass function evaluated at k.
.. math::
Expand Down Expand Up @@ -341,5 +341,5 @@ def kl_divergence(self, other):
)
else:
raise TypeError(
f"Exected type of other is geometric.Geometric, but got {type(other)}"
f"Exacted type of other is geometric.Geometric, but got {type(other)}"
)
16 changes: 8 additions & 8 deletions python/paddle/distribution/kl.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def kl_divergence(p, q):


def register_kl(cls_p, cls_q):
"""Decorator for register a KL divergence implemention function.
"""Decorator for register a KL divergence implementation function.
The ``kl_divergence(p, q)`` function will search concrete implemention
The ``kl_divergence(p, q)`` function will search concrete implementation
functions registered by ``register_kl``, according to multi-dispatch pattern.
If an implemention function is found, it will return the result, otherwise,
If an implementation function is found, it will return the result, otherwise,
it will raise ``NotImplementError`` exception. Users can register
implemention function by the decorator.
implementation function by the decorator.
Args:
cls_p (Distribution): The Distribution type of Instance p. Subclass derived from ``Distribution``.
Expand Down Expand Up @@ -110,16 +110,16 @@ def _dispatch(cls_p, cls_q):
"""Multiple dispatch into concrete implement function."""

# find all matched super class pair of p and q
matchs = [
matches = [
(super_p, super_q)
for super_p, super_q in _REGISTER_TABLE
if issubclass(cls_p, super_p) and issubclass(cls_q, super_q)
]
if not matchs:
if not matches:
raise NotImplementedError

left_p, left_q = min(_Compare(*m) for m in matchs).classes
right_p, right_q = min(_Compare(*reversed(m)) for m in matchs).classes
left_p, left_q = min(_Compare(*m) for m in matches).classes
right_p, right_q = min(_Compare(*reversed(m)) for m in matches).classes

if _REGISTER_TABLE[left_p, left_q] is not _REGISTER_TABLE[right_p, right_q]:
warnings.warn(
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/distribution/lognormal.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self, loc, scale):

@property
def mean(self):
"""Mean of lognormal distribuion.
"""Mean of lognormal distribution.
Returns:
Tensor: mean value.
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/distribution/multinomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, total_count, probs):

@property
def mean(self):
"""mean of multinomial distribuion.
"""mean of multinomial distribution.
Returns:
Tensor: mean value.
Expand Down
24 changes: 12 additions & 12 deletions python/paddle/distribution/multivariate_normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(
batch_shape
+ [precision_matrix.shape[-2], precision_matrix.shape[-1]]
)
self._check_constriants()
self._check_constraints()
self.loc = loc.expand(
batch_shape
+ [
Expand Down Expand Up @@ -223,16 +223,16 @@ def _check_positive_definite(self, value):
raise ValueError(
"covariance_matrix or precision_matrix must be a symmetric matrix"
)
is_postive_definite = (
is_positive_definite = (
paddle.cast(paddle.linalg.eigvalsh(value), dtype=self.dtype) > 0
).all()
return is_postive_definite
return is_positive_definite

def _check_constriants(self):
"""Check whether the matrix satisfy corresponding constriant
def _check_constraints(self):
"""Check whether the matrix satisfy corresponding constraint
Return:
Tensor: indicator for the pass of constriants check
Tensor: indicator for the pass of constraints check
"""
if self.scale_tril is not None:
check = self._check_lower_triangular(self.scale_tril)
Expand All @@ -241,25 +241,25 @@ def _check_constriants(self):
"scale_tril matrix must be a lower triangular matrix with positive diagonals"
)
elif self.covariance_matrix is not None:
is_postive_definite = self._check_positive_definite(
is_positive_definite = self._check_positive_definite(
self.covariance_matrix
)
if not is_postive_definite:
if not is_positive_definite:
raise ValueError(
"covariance_matrix must be a symmetric positive definite matrix"
)
else:
is_postive_definite = self._check_positive_definite(
is_positive_definite = self._check_positive_definite(
self.precision_matrix
)
if not is_postive_definite:
if not is_positive_definite:
raise ValueError(
"precision_matrix must be a symmetric positive definite matrix"
)

@property
def mean(self):
"""Mean of Multivariate Normal distribuion.
"""Mean of Multivariate Normal distribution.
Returns:
Tensor: mean value.
Expand Down Expand Up @@ -451,7 +451,7 @@ def precision_to_scale_tril(P):

def batch_mahalanobis(bL, bx):
r"""
Computes the squared Mahalanobis distance of the Multivariate Normal distribution with cholesky decomposition of the covatiance matrix.
Computes the squared Mahalanobis distance of the Multivariate Normal distribution with cholesky decomposition of the covariance matrix.
Accepts batches for both bL and bx.
Args:
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/distribution/normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __init__(self, loc, scale, name=None):

@property
def mean(self):
"""Mean of normal distribuion.
"""Mean of normal distribution.
Returns:
Tensor: mean value.
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/distribution/poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _check_constraint(self, value):

@property
def mean(self):
"""Mean of poisson distribuion.
"""Mean of poisson distribution.
Returns:
Tensor: mean value.
Expand Down
20 changes: 10 additions & 10 deletions python/paddle/distribution/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _is_injective(cls):

def __call__(self, input):
"""Make this instance as a callable object. The return value is
depening on the input type.
depending on the input type.
* If the input is a ``Tensor`` instance, return
``self.forward(input)`` .
Expand Down Expand Up @@ -160,7 +160,7 @@ def forward(self, x):
Useful for turning one random outcome into another.
Args:
x (Tensos): Input parameter, generally is a sample generated
x (Tensor): Input parameter, generally is a sample generated
from ``Distribution``.
Returns:
Expand Down Expand Up @@ -299,7 +299,7 @@ def _codomain(self):
return variable.real

def _forward(self, x):
"""Inner method for publid API ``forward``, subclass should
"""Inner method for public API ``forward``, subclass should
overwrite this method for supporting forward transformation.
"""
raise NotImplementedError('Forward not implemented')
Expand Down Expand Up @@ -340,8 +340,8 @@ def _forward_shape(self, shape):
return shape

def _inverse_shape(self, shape):
"""Inner method called by ``inverse_shape``, whic is used to infer the
invese shape. Subclass should overwrite this method for supporting
"""Inner method called by ``inverse_shape``, which is used to infer the
inverse shape. Subclass should overwrite this method for supporting
``inverse_shape``.
"""
return shape
Expand All @@ -355,7 +355,7 @@ class AbsTransform(Transform):
distributions with the absolute value function, which maps ``(-inf, inf)``
to ``[0, inf)`` .
* For ``y`` in ``(0, inf)`` , ``AbsTransform.inverse(y)`` returns the set invese
* For ``y`` in ``(0, inf)`` , ``AbsTransform.inverse(y)`` returns the set inverse
``{x in (-inf, inf) : |x| = y}`` as a tuple, ``-y, y`` .
* For ``y`` equal ``0`` , ``AbsTransform.inverse(0)`` returns ``0, 0``, which is not
the set inverse (the set inverse is the singleton {0}), but "works" in
Expand Down Expand Up @@ -681,13 +681,13 @@ class IndependentTransform(Transform):
some of the rightmost batch axes as event axes.
Generally, it is used to expand the event axes. This has no effect on the
forward or inverse transformaion, but does sum out the
``reinterpretd_bach_rank`` rightmost dimensions in computing the determinant
forward or inverse transformation, but does sum out the
``reinterpreted_batch_rank`` rightmost dimensions in computing the determinant
of Jacobian matrix.
To see this, consider the ``ExpTransform`` applied to a Tensor which has
sample, batch, and event ``(S,B,E)`` shape semantics. Suppose the Tensor's
paritioned-shape is ``(S=[4], B=[2, 2], E=[3])`` , reinterpreted_batch_rank
partitioned-shape is ``(S=[4], B=[2, 2], E=[3])`` , reinterpreted_batch_rank
is 1. Then the reinterpreted Tensor's shape is ``(S=[4], B=[2], E=[2, 3])`` .
The shape returned by ``forward`` and ``inverse`` is unchanged, ie,
``[4,2,2,3]`` . However the shape returned by ``inverse_log_det_jacobian``
Expand Down Expand Up @@ -875,7 +875,7 @@ def __init__(self, in_event_shape, out_event_shape):
):
raise TypeError(
f"Expected type of 'in_event_shape' and 'out_event_shape' is "
f"Squence[int], but got 'in_event_shape': {in_event_shape}, "
f"Sequence[int], but got 'in_event_shape': {in_event_shape}, "
f"'out_event_shape': {out_event_shape}"
)
in_size = 1
Expand Down

0 comments on commit 9d1196c

Please sign in to comment.