(position)
| 27 | return position / (10000 ** (2 * (hid_idx // 2) / d_hid)) |
| 28 | |
| 29 | def get_posi_angle_vec(position): |
| 30 | return [cal_angle(position, hid_j) for hid_j in range(d_hid)] |
| 31 | |
| 32 | sinusoid_table = torch.Tensor([get_posi_angle_vec(pos_i) for pos_i in range(n_position)]) |
| 33 | sinusoid_table[:, 0::2] = torch.sin(sinusoid_table[:, 0::2]) # dim 2i |
no test coverage detected