timesead.models.reconstruction.stgat ==================================== .. py:module:: timesead.models.reconstruction.stgat .. autoapi-nested-parse:: Code taken from https://github.com/zhanjun717/STGAT Classes ------- .. autoapisummary:: timesead.models.reconstruction.stgat.InputLayer timesead.models.reconstruction.stgat.StgatBlock timesead.models.reconstruction.stgat.BiLSTMLayer timesead.models.reconstruction.stgat.BiLSTMDecoder timesead.models.reconstruction.stgat.ReconstructionModel timesead.models.reconstruction.stgat.Forecasting_Model timesead.models.reconstruction.stgat.STGAT Functions --------- .. autoapisummary:: timesead.models.reconstruction.stgat.get_batch_edge_index timesead.models.reconstruction.stgat.get_fc_graph_struc timesead.models.reconstruction.stgat.get_tc_graph_struc Module Contents --------------- .. py:class:: InputLayer(n_features, kernel_size=7) Bases: :py:obj:`torch.nn.Module` 1-D Convolution layer to extract high-level features of each time-series input :param n_features: Number of input features/nodes :param window_size: length of the input sequence :param kernel_size: size of kernel to use in the convolution operation Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: padding .. py:attribute:: conv .. py:attribute:: relu .. py:method:: forward(x) .. py:class:: StgatBlock(n_features, window_size, dropout, alpha, embed_dim=None) 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:: n_features .. py:attribute:: window_size .. py:attribute:: dropout .. py:attribute:: alpha .. py:attribute:: embed_dim :value: None .. py:attribute:: feature_gat_layers .. py:attribute:: temporal_gat_layers .. py:attribute:: temporal_gcn_layers .. py:method:: forward(data, fc_edge_index, tc_edge_index) .. py:class:: BiLSTMLayer(in_dim, hid_dim, n_layers, dropout) 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:: hid_dim .. py:attribute:: n_layers .. py:attribute:: dropout :value: 0.0 .. py:attribute:: bilstm .. py:method:: forward(x) .. py:class:: BiLSTMDecoder(in_dim, hid_dim, n_layers, dropout) 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:: in_dim .. py:attribute:: dropout :value: 0.0 .. py:attribute:: bilstm .. py:method:: forward(x) .. py:class:: ReconstructionModel(window_size, in_dim, hid_dim, out_dim, n_layers, dropout) 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:: window_size .. py:attribute:: decoder .. py:attribute:: fc .. py:method:: forward(x) .. py:class:: Forecasting_Model(in_dim, hid_dim, out_dim, n_layers, dropout) 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:attribute:: dropout .. py:attribute:: relu .. py:method:: forward(x) .. py:function:: get_batch_edge_index(org_edge_index, batch_num, node_num) .. py:function:: get_fc_graph_struc(n_features) .. py:function:: get_tc_graph_struc(temporal_len) .. py:class:: STGAT(input_dim: int, window_size: int, embed_dim: int = None, layer_numb: int = 2, lstm_n_layers: int = 1, lstm_hid_dim: int = 150, recon_n_layers: int = 1, recon_hid_dim: int = 150, dropout: float = 0.2, alpha: float = 0.2) Bases: :py:obj:`timesead.models.BaseModel` 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:: layer_numb :value: 2 .. py:attribute:: h_temp :value: [] .. py:attribute:: input_1 .. py:attribute:: input_2 .. py:attribute:: input_3 .. py:attribute:: stgat_1 .. py:attribute:: stgat_2 .. py:attribute:: stgat_3 .. py:attribute:: bilstm .. py:attribute:: recon_model .. py:method:: forward(inputs)