dsipts.models.patchtst package

Submodules

dsipts.models.patchtst.layers module

dsipts.models.patchtst.layers.Coord1dPosEncoding(q_len, exponential=False, normalize=True)
dsipts.models.patchtst.layers.Coord2dPosEncoding(q_len, d_model, exponential=False, normalize=True, eps=0.001, verbose=False)
class dsipts.models.patchtst.layers.Flatten_Head(individual, n_vars, nf, target_window, head_dropout=0)

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class dsipts.models.patchtst.layers.PatchTST_backbone(c_in: int, context_window: int, target_window: int, patch_len: int, stride: int, max_seq_len: int | None = 1024, n_layers: int = 3, d_model=128, n_heads=16, d_k: int | None = None, d_v: int | None = None, d_ff: int = 256, norm: str = 'BatchNorm', attn_dropout: float = 0.0, dropout: float = 0.0, act: str = 'gelu', key_padding_mask: bool = 'auto', padding_var: int | None = None, attn_mask: Tensor | None = None, res_attention: bool = True, pre_norm: bool = False, store_attn: bool = False, pe: str = 'zeros', learn_pe: bool = True, fc_dropout: float = 0.0, head_dropout=0, padding_patch=None, pretrain_head: bool = False, head_type='flatten', individual=False, revin=True, affine=True, subtract_last=False, verbose: bool = False, **kwargs)

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

create_pretrain_head(head_nf, vars, dropout)
forward(z)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

dsipts.models.patchtst.layers.PositionalEncoding(q_len, d_model, normalize=True)
class dsipts.models.patchtst.layers.RevIN(num_features: int, eps=1e-05, affine=True, subtract_last=False)

Bases: Module

Parameters:
  • num_features – the number of features or channels

  • eps – a value added for numerical stability

  • affine – if True, RevIN has learnable affine parameters

forward(x, mode: str)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

dsipts.models.patchtst.layers.SinCosPosEncoding(q_len, d_model, normalize=True)
class dsipts.models.patchtst.layers.TSTEncoder(q_len, d_model, n_heads, d_k=None, d_v=None, d_ff=None, norm='BatchNorm', attn_dropout=0.0, dropout=0.0, activation='gelu', res_attention=False, n_layers=1, pre_norm=False, store_attn=False)

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(src: Tensor, key_padding_mask: Tensor | None = None, attn_mask: Tensor | None = None)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class dsipts.models.patchtst.layers.TSTEncoderLayer(q_len, d_model, n_heads, d_k=None, d_v=None, d_ff=256, store_attn=False, norm='BatchNorm', attn_dropout=0, dropout=0.0, bias=True, activation='gelu', res_attention=False, pre_norm=False)

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(src: Tensor, prev: Tensor | None = None, key_padding_mask: Tensor | None = None, attn_mask: Tensor | None = None) Tensor

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class dsipts.models.patchtst.layers.TSTiEncoder(c_in, patch_num, patch_len, max_seq_len=1024, n_layers=3, d_model=128, n_heads=16, d_k=None, d_v=None, d_ff=256, norm='BatchNorm', attn_dropout=0.0, dropout=0.0, act='gelu', store_attn=False, key_padding_mask='auto', padding_var=None, attn_mask=None, res_attention=True, pre_norm=False, pe='zeros', learn_pe=True, verbose=False, **kwargs)

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x) Tensor

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class dsipts.models.patchtst.layers.Transpose(*dims, contiguous=False)

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class dsipts.models.patchtst.layers.moving_avg(kernel_size, stride)

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

dsipts.models.patchtst.layers.positional_encoding(pe, learn_pe, q_len, d_model)
class dsipts.models.patchtst.layers.series_decomp(kernel_size)

Bases: Module

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Module contents