tcn#

class TemporalBlock(n_inputs, n_outputs, kernel_size, stride, dilation, padding, dropout=0.2)[source]#

The TCN block, consists of dilated causal conv, relu and residual block. See the Figure 1(b) in https://arxiv.org/pdf/1803.01271.pdf for more details.

Parameters:
  • n_inputs (int) – The number of channels in the input tensor.

  • n_outputs (int) – The number of filters.

  • kernel_size (int) – The filter size.

  • stride (int) – The stride size.

  • dilation (int) – The dilation size.

  • padding (int) – The size of zeros to be padded.

  • dropout (float, optional) – Probability of dropout the units. Defaults to 0.2.

forward(x)[source]#
Parameters:

x (Tensor) – The input tensor with a shape of [batch_size, input_channel, sequence_length].

class TCN(input_channel, num_channels, kernel_size=2, dropout=0.2)[source]#
forward(x)[source]#

Apply temporal convolutional networks to the input tensor.

Parameters:

x (Tensor) – The input tensor with a shape of [batch_size, input_channel, sequence_length].

Returns:

The output tensor with a shape of [batch_size, num_channels[-1], sequence_length].

Return type:

Tensor