***bijective** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – Whether this transform is bijective. A transform `t` is bijective iff `t.inv(t(x)) == x` and `t(t.inv(y)) == y` for every `x` in the domain and `y` in the codomain. Transforms that are not bijective should at least maintain the weaker pseudoinverse properties`t(t.inv(t(x)) == t(x)` and `t.inv(t(t.inv(y))) == t.inv(y)`.
Returns the inverse [`Transform`](#torch.distributions.transforms.Transform"torch.distributions.transforms.Transform") of this transform. This should satisfy`t.inv.inv is t`.
返回逆[`Transform`](#torch.distributions.transforms.Transform"torch.distributions.transforms.Transform"). 满足`t.inv.inv is t`.
```py
sign
```
Returns the sign of the determinant of the Jacobian, if applicable. In general this only makes sense for bijective transforms.
如果适用, 返回雅可比行列式的符号. 一般来说, 这只适用于双射变换.
```py
log_abs_det_jacobian(x,y)
```
Computes the log det jacobian `log |dy/dx|` given input and output.
Composes multiple transforms in a chain. The transforms being composed are responsible for caching.
在一个链中组合多个转换. 正在组合的转换负责缓存.
| 参数: | **parts** (list of [`Transform`](#torch.distributions.transforms.Transform"torch.distributions.transforms.Transform")) – A list of transforms to compose. |
***event_dim** ([_int_](https://docs.python.org/3/library/functions.html#int"(in Python v3.7)")) – Optional size of `event_shape`. This should be zero for univariate random variables, 1 for distributions over vectors, 2 for distributions over matrices, etc.
This is not bijective and cannot be used for HMC. However this acts mostly coordinate-wise (except for the final normalization), and thus is appropriate for coordinate-wise optimization algorithms.
Transform from unconstrained space to the simplex of one additional dimension via a stick-breaking process.
将无约束空间通过 stick-breaking 过程转化为一个额外维度的单纯形.
This transform arises as an iterated sigmoid transform in a stick-breaking construction of the `Dirichlet` distribution: the first logit is transformed via sigmoid to the first probability and the probability of everything else, and then the process recurses.
@@ -2598,12 +2597,12 @@ alias of `torch.distributions.constraints._HalfOpenInterval`
## `Constraint Registry`
PyTorch provides two global [`ConstraintRegistry`](#torch.distributions.constraint_registry.ConstraintRegistry"torch.distributions.constraint_registry.ConstraintRegistry") objects that link [`Constraint`](#torch.distributions.constraints.Constraint"torch.distributions.constraints.Constraint") objects to [`Transform`](#torch.distributions.transforms.Transform"torch.distributions.transforms.Transform") objects. These objects both input constraints and return transforms, but they have different guarantees on bijectivity.
1.`biject_to(constraint)`looks up a bijective [`Transform`](#torch.distributions.transforms.Transform"torch.distributions.transforms.Transform") from `constraints.real` to the given `constraint`. The returned transform is guaranteed to have `.bijective = True` and should implement`.log_abs_det_jacobian()`.
2.`transform_to(constraint)`looks up a not-necessarily bijective [`Transform`](#torch.distributions.transforms.Transform"torch.distributions.transforms.Transform") from `constraints.real` to the given `constraint`. The returned transform is not guaranteed to implement`.log_abs_det_jacobian()`.
The `transform_to()` registry is useful for performing unconstrained optimization on constrained parameters of probability distributions, which are indicated by each distribution’s `.arg_constraints` dict. These transforms often overparameterize a space in order to avoid rotation; they are thus more suitable for coordinate-wise optimization algorithms like Adam:
@@ -2613,7 +2612,7 @@ loss = -Normal(loc, scale).log_prob(data).sum()
```
The `biject_to()` registry is useful for Hamiltonian Monte Carlo, where samples from a probability distribution with constrained `.support` are propagated in an unconstrained space, and algorithms are typically rotation invariant.:
`biject_to()` 注册表对于Hamiltonian Monte Carlo非常有用, 其中来自具有约束. `.support`的概率分布的样本在无约束空间中传播, 并且算法通常是旋转不变的
An example where `transform_to` and `biject_to` differ is `constraints.simplex`: `transform_to(constraints.simplex)` returns a [`SoftmaxTransform`](#torch.distributions.transforms.SoftmaxTransform"torch.distributions.transforms.SoftmaxTransform") that simply exponentiates and normalizes its inputs; this is a cheap and mostly coordinate-wise operation appropriate for algorithms like SVI. In contrast, `biject_to(constraints.simplex)` returns a [`StickBreakingTransform`](#torch.distributions.transforms.StickBreakingTransform"torch.distributions.transforms.StickBreakingTransform") that bijects its input down to a one-fewer-dimensional space; this a more expensive less numerically stable transform but is needed for algorithms like HMC.
The `biject_to` and `transform_to` objects can be extended by user-defined constraints and transforms using their `.register()` method either as a function on singleton constraints:
You can create your own registry by creating a new [`ConstraintRegistry`](#torch.distributions.constraint_registry.ConstraintRegistry"torch.distributions.constraint_registry.ConstraintRegistry") object.
***constraint** (subclass of [`Constraint`](#torch.distributions.constraints.Constraint"torch.distributions.constraints.Constraint")) – A subclass of [`Constraint`](#torch.distributions.constraints.Constraint"torch.distributions.constraints.Constraint"), or a singleton object of the desired class.
***factory** (_callable_) – A callable that inputs a constraint object and returns a [`Transform`](#torch.distributions.transforms.Transform"torch.distributions.transforms.Transform") object.
***constraint** (subclass of [`Constraint`](#torch.distributions.constraints.Constraint"torch.distributions.constraints.Constraint")) – [`Constraint`]的子类(#torch.distributions.constraints.Constraint "torch.distributions.constraints.Constraint"), 或者派生类的对象.