torch_frame.nn.encoder.TimestampEncoder
- class TimestampEncoder(out_channels: Optional[int] = None, stats_list: Optional[list[dict[torch_frame.data.stats.StatType, Any]]] = None, stype: Optional[stype] = None, post_module: Optional[Module] = None, na_strategy: torch_frame.typing.NAStrategy | None = NAStrategy.MEDIAN_TIMESTAMP, out_size: int = 8)[source]
Bases:
StypeEncoderTimestampEncoder for timestamp stype. Year is encoded with
torch_frame.nn.encoding.PositionalEncoding. The other features, including month, day, dayofweek, hour, minute and second, are encoded usingtorch_frame.nn.encoding.CyclicEncoding. It applies linear layer for each column in a batched manner. The TimestampEncoder does not support NaN timestamps, becausetorch_frame.nn.encoding.PositionalEncodingdoes not support negative tensor values. Sotorch_frame.NAStrategy.MEDIAN_TIMESTAMPis applied as the defaultNAStrategy.- Parameters:
out_size (int) – Output dimension of the positional and cyclic encodings.