torch_geometric.nn.encoding.TemporalEncoding
- class TemporalEncoding(out_channels: int, device: Optional[device] = None)[source]
Bases:
ModuleThe time-encoding function from the “Do We Really Need Complicated Model Architectures for Temporal Networks?” paper.
It first maps each entry to a vector with exponentially decreasing values, and then uses the cosine function to project all values to range \([-1, 1]\).
\[y_{i} = \cos \left(x \cdot \sqrt{d}^{-(i - 1)/\sqrt{d}} \right)\]where \(d\) defines the output feature dimension, and \(1 \leq i \leq d\).
- Parameters:
out_channels (int) – Size \(d\) of each output sample.
device (torch.device, optional) – The device of the module. (default:
None)