timesead.models.reconstruction.etsformer ======================================== .. py:module:: timesead.models.reconstruction.etsformer Classes ------- .. autoapisummary:: timesead.models.reconstruction.etsformer.ExponentialSmoothing timesead.models.reconstruction.etsformer.Feedforward timesead.models.reconstruction.etsformer.GrowthLayer timesead.models.reconstruction.etsformer.FourierLayer timesead.models.reconstruction.etsformer.LevelLayer timesead.models.reconstruction.etsformer.EncoderLayer timesead.models.reconstruction.etsformer.Encoder timesead.models.reconstruction.etsformer.DampingLayer timesead.models.reconstruction.etsformer.DecoderLayer timesead.models.reconstruction.etsformer.Decoder timesead.models.reconstruction.etsformer.ETSformer Functions --------- .. autoapisummary:: timesead.models.reconstruction.etsformer.conv1d_fft Module Contents --------------- .. py:function:: conv1d_fft(f, g, dim=-1) .. py:class:: ExponentialSmoothing(dim, nhead, dropout=0.1, aux=False) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: v0 .. py:attribute:: dropout .. py:method:: forward(values, aux_values=None) .. py:method:: get_exponential_weight(T) .. py:property:: weight .. py:class:: Feedforward(d_model, dim_feedforward, dropout=0.1, activation='sigmoid') Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: linear1 .. py:attribute:: dropout1 .. py:attribute:: linear2 .. py:attribute:: dropout2 .. py:attribute:: activation .. py:method:: forward(x) .. py:class:: GrowthLayer(d_model, nhead, d_head=None, dropout=0.1) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: d_head .. py:attribute:: d_model .. py:attribute:: nhead .. py:attribute:: z0 .. py:attribute:: in_proj .. py:attribute:: es .. py:attribute:: out_proj .. py:method:: forward(inputs) :param inputs: shape: (batch, seq_len, dim) :return: shape: (batch, seq_len, dim) .. py:class:: FourierLayer(d_model, pred_len, k=None, low_freq=1) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: d_model .. py:attribute:: pred_len .. py:attribute:: k :value: None .. py:attribute:: low_freq :value: 1 .. py:method:: forward(x) x: (b, t, d) .. py:method:: extrapolate(x_freq, f, t) .. py:method:: topk_freq(x_freq) .. py:class:: LevelLayer(d_model, c_out, dropout=0.1) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: d_model .. py:attribute:: c_out .. py:attribute:: es .. py:attribute:: growth_pred .. py:attribute:: season_pred .. py:method:: forward(level, growth, season) .. py:class:: EncoderLayer(d_model, nhead, c_out, seq_len, pred_len, k, dim_feedforward=None, dropout=0.1, activation='sigmoid', layer_norm_eps=1e-05) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: d_model .. py:attribute:: nhead .. py:attribute:: c_out .. py:attribute:: seq_len .. py:attribute:: pred_len .. py:attribute:: dim_feedforward .. py:attribute:: growth_layer .. py:attribute:: seasonal_layer .. py:attribute:: level_layer .. py:attribute:: ff .. py:attribute:: norm1 .. py:attribute:: norm2 .. py:attribute:: dropout1 .. py:attribute:: dropout2 .. py:method:: forward(res, level, attn_mask=None) .. py:class:: Encoder(layers) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: layers .. py:method:: forward(res, level, attn_mask=None) .. py:class:: DampingLayer(pred_len, nhead, dropout=0.1) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: pred_len .. py:attribute:: nhead .. py:attribute:: dropout .. py:method:: forward(x) .. py:property:: damping_factor .. py:class:: DecoderLayer(d_model, nhead, c_out, pred_len, dropout=0.1) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: d_model .. py:attribute:: nhead .. py:attribute:: c_out .. py:attribute:: pred_len .. py:attribute:: growth_damping .. py:attribute:: dropout1 .. py:method:: forward(growth, season) .. py:class:: Decoder(layers) Bases: :py:obj:`torch.nn.Module` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: d_model .. py:attribute:: c_out .. py:attribute:: pred_len .. py:attribute:: nhead .. py:attribute:: layers .. py:attribute:: pred .. py:method:: forward(growths, seasons) .. py:class:: ETSformer(window_size: int, input_dim: int, model_dim: int = 128, dropout: float = 0.1, num_heads: int = 8, fcn_dim: int = 128, encoder_layers: int = 3, activation: str = 'gelu', top_k: int = 5) Bases: :py:obj:`timesead.models.BaseModel` Paper link: https://arxiv.org/abs/2202.01381 Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: seq_len .. py:attribute:: enc_embedding .. py:attribute:: encoder .. py:attribute:: decoder .. py:method:: forward(inputs: Tuple[torch.Tensor, Ellipsis]) -> Tuple[torch.Tensor, Ellipsis]