From 383c9fd43da4ccdcd74bc76a3b28ba385b5d1044 Mon Sep 17 00:00:00 2001 From: Fredo Guan Date: Wed, 18 Jan 2023 12:12:26 -0800 Subject: [PATCH] Update metaformers.py --- timm/models/metaformers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timm/models/metaformers.py b/timm/models/metaformers.py index 771a0319..7a41cf2a 100644 --- a/timm/models/metaformers.py +++ b/timm/models/metaformers.py @@ -179,10 +179,10 @@ class RandomMixing(nn.Module): data=torch.softmax(torch.rand(num_tokens, num_tokens), dim=-1), requires_grad=False) def forward(self, x): - B, C, H, W = x.shape + B, H, W, C = x.shape x = x.reshape(B, H*W, C) 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