-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
在lsnet/model/lsnet.py尝试如下代码:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model =LSNet().to(device)
x = torch.randn(1, 3, 224, 224).to(device)
out = model(x)
报错:
RuntimeError: The size of tensor a (16) must match the size of tensor b (4) at non-singleton dimension 3
定位:
Attention类中,
attn = (
(q.transpose(-2, -1) @ k) * self.scale
+
(self.attention_biases[:, self.attention_bias_idxs]
if self.training else self.ab)
)
两个tensor形状不匹配,(q.transpose(-2, -1) @ k) * self.scale.shape = torch.size[1,4,16,16]; (self.attention_biases[:, self.attention_bias_idxs]
if self.training else self.ab).shape = torch.size[4,4,4]
Metadata
Metadata
Assignees
Labels
No labels