(self, in_dim, out_dim, has_pos_emb=False)
| 56 | |
| 57 | class MLP(torch.nn.Module): |
| 58 | def __init__(self, in_dim, out_dim, has_pos_emb=False): |
| 59 | super().__init__() |
| 60 | self.proj = torch.nn.Sequential( |
| 61 | nn.LayerNorm(in_dim), |
| 62 | nn.Linear(in_dim, in_dim), |
| 63 | nn.GELU(), |
| 64 | nn.Linear(in_dim, out_dim), |
| 65 | nn.LayerNorm(out_dim) |
| 66 | ) |
| 67 | self.has_pos_emb = has_pos_emb |
| 68 | if has_pos_emb: |
| 69 | self.emb_pos = torch.nn.Parameter(torch.zeros((1, 514, 1280))) |
| 70 | |
| 71 | def forward(self, x): |
| 72 | if self.has_pos_emb: |