Apply positional encoding to the input.
(self, tensor)
| 572 | self.bvals = nn.Parameter(bvals, requires_grad=False) |
| 573 | |
| 574 | def forward(self, tensor) -> torch.Tensor: |
| 575 | """ |
| 576 | Apply positional encoding to the input. |
| 577 | """ |
| 578 | |
| 579 | return torch.cat([self.avals * torch.sin((2.*np.pi*tensor) @ self.bvals.T), |
| 580 | self.avals * torch.cos((2.*np.pi*tensor) @ self.bvals.T)], dim=-1) |
| 581 | |
| 582 | |
| 583 | class PositionalEncoding(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected