torch_frame.nn.encoding.CyclicEncoding

class CyclicEncoding(out_size: int)[source]

Bases: Module

Cyclic encoding for input data containing values between 0 and 1. This function maps each value in the input using sine and cosine functions of different wavelengths to preserve the cyclical nature. This is particularly useful for encoding cyclical features like hours of a day, days of the week, etc. Given an input tensor of shape (*, ), this encoding expands it into an output tensor of shape (*, out_size).

Parameters:

out_size (int) – The output dimension size.

forward(input_tensor: Tensor) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.