Skip to content

模型测试 #7

@suse955

Description

@suse955

在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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions