Pytorch学习
文章平均质量分 55
Aleafy
这个作者很懒,什么都没留下…
展开
-
torch.tensor与torch.Tensor的使用说明
问题描述在使用pytorch进行softmax,得出每个类别的预测值,再进行NLLloss计算损失函数时,如果真实值是由torch.Tensor构造出来的,会报错:代码如下:import torch.nn as nntorch.manual_seed(1)input = torch.randn(3,3)#随机化输入张量sm = nn.Softmax(dim=1)#构造softmax层input = torch.log(sm(input))#计算softmax后预测值的对数loss原创 2021-07-27 21:14:23 · 583 阅读 · 0 评论 -
取消Pytorch警告
问题描述在训练模型过程中,打印损失函数值的过程中如果出现很多如下警告信息,非常影响观感和对比。警告信息为:UserWarning: size_average and reduce args will be deprecated,please use reduction=‘mean’ instead. warnings.warn(warning.format(ret))为pytorch不同版本进行更新迭代时引起的警告,某些参数被取代了更多细节参考Pytorch版本代码修正解决方案crite原创 2021-07-26 00:05:08 · 7166 阅读 · 7 评论