Args: coord_dim: the dimention of space, 2D, 3D, or other frequency_num: the number of different sinusoidal with different frequencies/wavelengths max_radius: the largest context radius this model can handle
(self, coord_dim=2, frequency_num=16,
max_radius=10000, min_radius=1000, freq_init="geometric")
| 17 | """ |
| 18 | |
| 19 | def __init__(self, coord_dim=2, frequency_num=16, |
| 20 | max_radius=10000, min_radius=1000, freq_init="geometric"): |
| 21 | """ |
| 22 | Args: |
| 23 | coord_dim: the dimention of space, 2D, 3D, or other |
| 24 | frequency_num: the number of different sinusoidal with different frequencies/wavelengths |
| 25 | max_radius: the largest context radius this model can handle |
| 26 | """ |
| 27 | super(Theory, self).__init__() |
| 28 | self.frequency_num = frequency_num |
| 29 | self.coord_dim = coord_dim |
| 30 | self.max_radius = max_radius |
| 31 | self.min_radius = min_radius |
| 32 | self.freq_init = freq_init |
| 33 | |
| 34 | # the frequence we use for each block, alpha in ICLR paper |
| 35 | self.cal_freq_list() |
| 36 | self.cal_freq_mat() |
| 37 | |
| 38 | # there unit vectors which is 120 degree apart from each other |
| 39 | self.unit_vec1 = np.asarray([1.0, 0.0]) # 0 |
| 40 | self.unit_vec2 = np.asarray([-1.0 / 2.0, math.sqrt(3) / 2.0]) # 120 degree |
| 41 | self.unit_vec3 = np.asarray([-1.0 / 2.0, -math.sqrt(3) / 2.0]) # 240 degree |
| 42 | |
| 43 | self.embedding_dim = self.cal_embedding_dim() |
| 44 | |
| 45 | def cal_freq_list(self): |
| 46 | self.freq_list = _cal_freq_list(self.freq_init, self.frequency_num, self.max_radius, self.min_radius) |
nothing calls this directly
no test coverage detected