MCPcopy Create free account
hub / github.com/ServiceNow/TACTiS / forward

Method forward

tactis/model/tactis.py:63–83  ·  view source on GitHub ↗

Parameters: ----------- input_encoded: torch.Tensor [batch, series, time steps, embedding dimension] An embedding which will be modified by the position encoding. timesteps: torch.IntTensor [batch, series, time steps] or [batch, 1, time steps]

(self, input_encoded: torch.Tensor, timesteps: torch.IntTensor)

Source from the content-addressed store, hash-verified

61 self.register_buffer("pos_encoding", pos_encoding)
62
63 def forward(self, input_encoded: torch.Tensor, timesteps: torch.IntTensor) -> torch.Tensor:
64 """
65 Parameters:
66 -----------
67 input_encoded: torch.Tensor [batch, series, time steps, embedding dimension]
68 An embedding which will be modified by the position encoding.
69 timesteps: torch.IntTensor [batch, series, time steps] or [batch, 1, time steps]
70 The time step for each entry in the input.
71
72 Returns:
73 --------
74 output_encoded: torch.Tensor [batch, series, time steps, embedding dimension]
75 The modified embedding.
76 """
77 # Use the time difference between the first time step of each batch and the other time steps.
78 # min returns two outputs, we only keep the first.
79 min_t = timesteps.min(dim=1, keepdim=True)[0].min(dim=2, keepdim=True)[0]
80 delta_t = timesteps - min_t
81
82 output_encoded = input_encoded + self.pos_encoding[delta_t]
83 return self.dropout(output_encoded)
84
85
86class NormalizationIdentity:

Callers 5

lossMethod · 0.45
sampleMethod · 0.45

Calls

no outgoing calls