torch_frame.nn.encoding.PositionalEncoding
- class PositionalEncoding(out_size: int)[source]
Bases:
ModulePositional encoding introduced in “Attention Is All You Need” paper. 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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.