m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMarcin Chrzanowski <m@m-chrzan.xyz>2021-05-23 13:19:47 +0200
committerMarcin Chrzanowski <m@m-chrzan.xyz>2021-05-23 13:19:47 +0200
commit1669b1b3757d663bfcff5981bea5b0ba25c08806 (patch)
tree11f3f823add686e1d752c7af80952f8d76d0b768 /util
parent49f264647b6073c304936a95fea1704a8c0965dc (diff)
Add positinal encoding placeholder
Diffstat (limited to 'util')
-rw-r--r--util/__init__.py0
-rw-r--r--util/util.py9
2 files changed, 9 insertions, 0 deletions
diff --git a/util/__init__.py b/util/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/util/__init__.py
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)