|
|
@ -179,10 +179,10 @@ class RandomMixing(nn.Module):
|
|
|
|
data=torch.softmax(torch.rand(num_tokens, num_tokens), dim=-1),
|
|
|
|
data=torch.softmax(torch.rand(num_tokens, num_tokens), dim=-1),
|
|
|
|
requires_grad=False)
|
|
|
|
requires_grad=False)
|
|
|
|
def forward(self, x):
|
|
|
|
def forward(self, x):
|
|
|
|
B, C, H, W = x.shape
|
|
|
|
B, H, W, C = x.shape
|
|
|
|
x = x.reshape(B, H*W, C)
|
|
|
|
x = x.reshape(B, H*W, C)
|
|
|
|
x = torch.einsum('mn, bnc -> bmc', self.random_matrix, x)
|
|
|
|
x = torch.einsum('mn, bnc -> bmc', self.random_matrix, x)
|
|
|
|
x = x.reshape(B, C, H, W)
|
|
|
|
x = x.reshape(B, H, W, C)
|
|
|
|
return x
|
|
|
|
return x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|