海宁:打造“红领青训营” 解题基层党建队伍培养

class paddle.distribution. ChainTransform ( transforms: Sequence[Transform] ) [source]
百度 女性面临的巨大的结婚压力已经造成了破坏性的经济后果,很多女性因为害怕结不成婚而被迫接受了与男友或丈夫之间并不平等的财务安排。

Composes multiple transforms in a chain.

Parameters

transforms (Sequence[Transform]) – A sequence of transformations.

Examples

>>> import paddle


>>> x = paddle.to_tensor([0., 1., 2., 3.])

>>> chain = paddle.distribution.ChainTransform((
...     paddle.distribution.AffineTransform(
...         paddle.to_tensor(0.), paddle.to_tensor(1.)),
...     paddle.distribution.ExpTransform()
>>> ))
>>> print(chain.forward(x))
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [1.         , 2.71828175 , 7.38905621 , 20.08553696])
>>> print(chain.inverse(chain.forward(x)))
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [0., 1., 2., 3.])
>>> print(chain.forward_log_det_jacobian(x))
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [0., 1., 2., 3.])
>>> print(chain.inverse_log_det_jacobian(chain.forward(x)))
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [ 0., -1., -2., -3.])
forward ( x: Tensor ) Tensor

forward?

Forward transformation with mapping \(y = f(x)\).

Useful for turning one random outcome into another.

Parameters

x (Tensor) – Input parameter, generally is a sample generated from Distribution.

Returns

Outcome of forward transformation.

Return type

Tensor

forward_log_det_jacobian ( x: Tensor ) Tensor

forward_log_det_jacobian?

The log of the absolute value of the determinant of the matrix of all first-order partial derivatives of the inverse function.

Parameters

x (Tensor) – Input tensor, generally is a sample generated from Distribution

Returns

The log of the absolute value of Jacobian determinant.

Return type

Tensor

forward_shape ( shape: Sequence[int] ) Sequence[int]

forward_shape?

Infer the shape of forward transformation.

Parameters

shape (Sequence[int]) – The input shape.

Returns

The output shape.

Return type

Sequence[int]

inverse ( y: Tensor ) Tensor

inverse?

Inverse transformation \(x = f^{-1}(y)\). It’s useful for “reversing” a transformation to compute one probability in terms of another.

Parameters

y (Tensor) – Input parameter for inverse transformation.

Returns

Outcome of inverse transform.

Return type

Tensor

inverse_log_det_jacobian ( y: Tensor ) Tensor

inverse_log_det_jacobian?

Compute \(log|det J_{f^{-1}}(y)|\). Note that forward_log_det_jacobian is the negative of this function, evaluated at \(f^{-1}(y)\).

Parameters

y (Tensor) – The input to the inverse Jacobian determinant evaluation.

Returns

The value of \(log|det J_{f^{-1}}(y)|\).

Return type

Tensor

inverse_shape ( shape: Sequence[int] ) Sequence[int]

inverse_shape?

Infer the shape of inverse transformation.

Parameters

shape (Sequence[int]) – The input shape of inverse transformation.

Returns

The output shape of inverse transformation.

Return type

Sequence[int]