Update metaformers.py

This commit is contained in:
Fredo Guan 2023-01-18 12:30:37 -08:00
parent 9a415a6041
commit 61b4e716ca

View File

@ -180,7 +180,7 @@ 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)
''' '''
self.random_matrix = torch.softmax(torch.rand(num_tokens, num_tokens)) self.random_matrix = torch.softmax(torch.rand(num_tokens, num_tokens), dim=-1)
def forward(self, x): def forward(self, x):
B, H, W, C = x.shape B, H, W, C = x.shape
x = x.reshape(B, H*W, C) x = x.reshape(B, H*W, C)