zhusuan.transforms.invertible.coupling

class AdditiveCoupling(in_out_dim=- 1, mid_dim=- 1, hidden=- 1, mask=None, inner_nn=None)[source]

Bases: zhusuan.transforms.invertible.base.InvertibleTransform

Additive coupling layer. Computes the following process and its inverse process:

\[ \begin{align}\begin{aligned}&\mathbf x_{I_1}, \mathbf x_{I_2} = \text{split}(\mathbf h_{i - 1})\\&\mathbf y_{I_1} = \mathbf x_{I_1}, \ \ \mathbf y_{I_2} = \mathbf x_{I_2} + m(\mathbf x_{I_1}) \\&\mathbf h_{i} = f_{i}(\mathbf h_{i - 1}) = \text{concat}(\mathbf y_{I_1}, \mathbf y_{I_2})\end{aligned}\end{align} \]

The layer provides a default fully connected layers which are similar to NICE paper [DKB15], or you can use any customize network using the inner_nn parameter.

Parameters
  • in_out_dim – The dim of the Var to be transformed.

  • mid_dim – The middle dim of the default net.

  • hidden – The number of hidden layers of the default net/

Mask

The mask Var acting on this coupling layer.

Inner_nn

The customize inner network.

References

DKB15

Laurent Dinh, David Krueger, and Yoshua Bengio. Nice: non-linear independent components estimation. 2015. arXiv:1410.8516.

get_coupling_mask(n_dim, n_channel, n_mask, split_type='ChessBoard')[source]

Mask generator for coupling layers.

Parameters
  • n_dim – The number of the dim which to be divided.

  • n_channel – The channel of the Var.

  • n_mask – The number of masks Var to be generated.

  • split_type – The way to divide the var in coupling layer. Only the default Chessboard(or OddEven) way is supported now.

Returns

A list of Var, which will be applied to the original Var on each coupling layer.