帮我改造模型class DARA(nn.Module): def init(self, dim=1024, reductionratio=4): super().init()…
- User
帮我改造模型class DARA(nn.Module): def init(self, dim=1024, reduction_ratio=4): super().init() self.mlp = nn.Sequential( nn.Linear(dim, dim // reduction_ratio), nn.ReLU(inplace=True), nn.Linear(dim // reduction_ratio, dim), nn.Softmax(dim=-1) ) self.domain_token = nn.Parameter(torch.zeros(1, 100, dim)) nn.init.normal_(self.domain_token, std=0.02)
def forward(self, x): # x is expected to be of shape (B, N, C) ViT output domain_token = self.domain_token.expand(x.size(0), -1, -1) attn = torch.einsum('bnd,bmd->bnm', x, domain_token) attn = self.mlp(attn) x_attn = torch.einsum('bnm,bnd->bmd', attn, x) x_out = x + x_attn return x_out Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.