【发布时间】:2021-08-09 08:51:12
【问题描述】:
我正在做一个二元分类,因此我使用了二元交叉熵损失:
criterion = torch.nn.BCELoss()
但是,我收到一个错误:
Using a target size (torch.Size([64, 1])) that is different to the input size (torch.Size([64, 2])) is deprecated. Please ensure they have the same size.
我的模型以:
结尾 x = self.wave_block6(x)
x = self.sigmoid(self.fc(x))
return x.squeeze()
我尝试移除挤压,但无济于事。我的批量大小是 64。似乎我在这里做错了一些简单的事情。我的模型是否提供 1 个输出和预期 2 个输入的 BCE 损失?那我应该使用哪个损失?
【问题讨论】:
-
你的模型应该有单输出.....
-
尝试添加更多信息
标签: pytorch