Absolute position
1 | def position_matrix(start=0, stop=2, T=2, n=4): |
In forward:
1 | ppmm = self.position_mat[:x.size(1)].repeat(x.size(0), 1, 1) |
In main:
1 | num = 90; n = 12 # num---seq_len; n---input_dim |
1 | def position_matrix(start=0, stop=2, T=2, n=4): |
In forward:
1 | ppmm = self.position_mat[:x.size(1)].repeat(x.size(0), 1, 1) |
In main:
1 | num = 90; n = 12 # num---seq_len; n---input_dim |
Author: Yanlan Hu
Permalink: http://example.com/2023/09/24/2023-9-24-Self-attention-position-embedding/
License: Copyright (c) 2019 CC-BY-NC-4.0 LICENSE