TimeCNNEncoder#

class TimeCNNEncoder(in_dim, out_dim, hidden_channels, horizon, activation=ReLU(), normalize=False, bias=True, mlp_hidden=[128], downsample='stride', append_last_frame=False, init_scheme='xavier_uniform')[source]#

Bases: Module

1D CNN baseline encoder for inputs of shape (N, in_dim, H).

The model applies a stack of 1D conv blocks over time. Each block halves the time horizon using either stride-2 convolution or max-pooling. The final feature map of shape (N, C_L, H_out) is flattened and passed to a 1-hidden-layer MLP head.

The encoder defines:

\[\mathbf{f}_{\mathbf{\theta}}: \mathbb{R}^{d_{\mathrm{in}}\times H} \to \mathbb{R}^{d_{\mathrm{out}}}.\]

This class does not impose group-equivariance constraints on channel transforms. It is an unconstrained baseline.

Parameters:
  • in_dim (int) – Input channel dimension.

  • out_dim (int) – Output feature dimension.

  • hidden_channels (list[int]) – Channels per conv block; depth equals len(hidden_channels).

  • horizon (int) – Input sequence length H.

  • activation (Module) – Activation module or list (one per block). If a single module is given, it is replicated for all blocks.

  • batch_norm – If True, add RMSNorm after each convolution.

  • bias (bool) – Use bias in conv/linear layers.

  • mlp_hidden (list[int]) – Hidden units of the final MLP head (list for deeper heads).

  • downsample (str) – “stride” (default) or “pooling”; each block halves H.

  • append_last_frame (bool) – If True, concatenate x[:, :, -1] (N, in_dim) to flattened conv features before the MLP.

  • normalize (bool)

  • init_scheme (str | None)

Returns:

Tensor of shape (N, out_dim).

forward(x)[source]#

Forward pass.

Parameters:

x (torch.Tensor) – Input tensor of shape (N, in_dim, H).

Returns:

Encoded tensor of shape (N, out_dim).

Return type:

torch.Tensor