(self, coords)
| 15 | self.embedding_dim = 4 |
| 16 | |
| 17 | def forward(self, coords): |
| 18 | # place lon lat coordinates in a -pi, pi range |
| 19 | coords = torch.deg2rad(coords) |
| 20 | |
| 21 | cos_lon = torch.cos(coords[:, 0]).unsqueeze(-1) |
| 22 | sin_lon = torch.sin(coords[:, 0]).unsqueeze(-1) |
| 23 | cos_lat = torch.cos(coords[:, 1]).unsqueeze(-1) |
| 24 | sin_lat = torch.sin(coords[:, 1]).unsqueeze(-1) |
| 25 | |
| 26 | return torch.cat((cos_lon, sin_lon, cos_lat, sin_lat), 1) |