From 1669b1b3757d663bfcff5981bea5b0ba25c08806 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 23 May 2021 13:19:47 +0200 Subject: Add positinal encoding placeholder --- util/__init__.py | 0 util/util.py | 9 +++++++++ 2 files changed, 9 insertions(+) create mode 100644 util/__init__.py create mode 100644 util/util.py diff --git a/util/__init__.py b/util/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/util/util.py b/util/util.py new file mode 100644 index 0000000..102ad93 --- /dev/null +++ b/util/util.py @@ -0,0 +1,9 @@ +import torch +import numpy as np + +def get_positional_encoding(n_positions, n_dimensions, device='cpu'): + # TODO: implement positional encoding + positional_encoding = np.zeros((n_positions, n_dimensions)) # placeholder + pass + # output shape: (seqlen, hiddendim) + return torch.tensor(positional_encoding, dtype=torch.float, device=device) -- cgit v1.2.3