Numpy, PyTorch, Einops (for some modules), PyTorch Lightning (for training routines)
pip install einops
pip install pytorch_lightning
Generalized Fourier / sinusoidal embedding modules for arbitrary real-valued tensor inputs in PyTorch
Each of the following files contains a standalone embedding layer:
sinusoidal_embedding.py
: TheSinusoidalEmbedding
layer has the same input-output interface(*)->(*, H)
as PyTorch'snn.Embedding
layer, except it's not trainable. It implements a generalized version of positional encoding in Transformer, supports more wavelength options, and accepts input tensors of arbitrary shape.