pytorch 错误:
1.ValueError: Using a target size (torch.Size([442])) that is different to
the input size (torch.Size([442, 1])) is deprecated. Please ensure they have
the same size.
报错信息说输入的尺寸和目标尺寸不同,导致的错误。

在前馈函数中 添加x = x.squeeze(-1) 达到降维就可以解决该问题。

2.UserWarning: size_average and reduce args will be deprecated, please use
reduction=‘sum’ instead. warnings.warn(warning.format(ret))
这是pytorch版本迭代引出的问题, 修改如下
criterion = torch.nn.BCELoss(size_average=True) #改为: criterion = torch.nn.
BCELoss(reduction='mean') criterion = torch.nn.BCELoss(size_average=False) #改为:
criterion= torch.nn.BCELoss(reduction='sum') #其它loss_function更改方法类似

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信