gluonts.mx.block.cnn module#

class gluonts.mx.block.cnn.CausalConv1D(channels: int, kernel_size: Union[int, Tuple[int], List[int]], dilation: Union[int, Tuple[int], List[int]] = 1, activation: Optional[str] = None, **kwargs)[source]#

Bases: mxnet.gluon.block.HybridBlock

1D causal temporal convolution, where the term causal means that output[t] does not depend on input[t+1:]. Notice that Conv1D is not implemented in Gluon.

This is the basic structure used in Wavenet [ODZ+16] and Temporal Convolution Network [BKK18].

The output has the same shape as the input, while we always left-pad zeros.

Parameters
  • channels – The dimensionality of the output space, i.e. the number of output channels (filters) in the convolution.

  • kernel_size – Specifies the dimensions of the convolution window.

  • dilation – Specifies the dilation rate to use for dilated convolution.

  • activation – Activation function to use. See Activation(). If you don’t specify anything, no activation is applied (ie. “linear” activation: a(x) = x).

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

In Gluon’s conv1D implementation, input has dimension NCW where N is batch_size, C is channel, and W is time (sequence_length).

Parameters

data – Shape (batch_size, num_features, sequence_length)

Returns

causal conv1d output. Shape (batch_size, num_features, sequence_length)

Return type

Tensor

class gluonts.mx.block.cnn.DilatedCausalGated(inner_channels: int, out_channels: int, kernel_size: Union[int, Tuple[int], List[int]], dilation: Union[int, Tuple[int], List[int]], **kwargs)[source]#

Bases: mxnet.gluon.block.HybridBlock

1D convolution with Gated mechanism, see the Wavenet papers described above.

Parameters
  • inner_channels – The dimensionality of the intermediate space

  • out_channels – The dimensionality of the output space

  • kernel_size – Specifies the dimensions of the convolution window.

  • dilation – Specifies the dilation rate to use for dilated convolution.

hybrid_forward(F, x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Compute the 1D convolution with Gated mechanism.

Parameters

x – input features, shape (batch_size, num_features, sequence_length)

Returns

output, shape (batch_size, num_features, sequence_length)

Return type

Tensor

class gluonts.mx.block.cnn.ResidualSequential(**kwargs)[source]#

Bases: mxnet.gluon.nn.basic_layers.HybridSequential

Adding residual connection to each layer of the hybrid sequential blocks.

hybrid_forward(F, x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#
Parameters
  • F – A module that can either refer to the Symbol API or the NDArray API in MXNet.

  • x – input tensor

Returns

output of the ResidualSequential

Return type

Tensor