pytorch MSELoss参数详解「建议收藏」

pytorch MSELoss参数详解「建议收藏」pytorchMSELoss参数详解importtorchimportnumpyasnploss_fn=torch.nn.MSELoss(reduce=False,size_average=False)a=np.array([[1,2],[3,8]])b=np.array([[5,4],[6,2]])input=torch.autograd.Variable(to…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

pytorch MSELoss参数详解

import torch
import numpy as np
loss_fn = torch.nn.MSELoss(reduce=False, size_average=False)
a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)

loss_fn = torch.nn.MSELoss(reduce=False, size_average=True)
a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)

a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
loss_fn = torch.nn.MSELoss(reduce=True, size_average=False)
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)

a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
loss_fn = torch.nn.MSELoss(reduce=True, size_average=True)
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)

a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
loss_fn = torch.nn.MSELoss()##reduce=True, size_average=True
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)

loss_fn = torch.nn.MSELoss(reduction = 'none')
a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)

loss_fn = torch.nn.MSELoss(reduction = 'sum')
a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)

loss_fn = torch.nn.MSELoss(reduction = 'none')
a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)

loss_fn = torch.nn.MSELoss(reduction = 'elementwise_mean')
a=np.array([[1,2],[3,8]])
b=np.array([[5,4],[6,2]])
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)



版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/192085.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • TS流批量下载工具

    TS流批量下载工具工具目录下有3个文件ffmpeg.exe:主要用来处理TS文件转为PM4文件用到,可以自行到相关网站下载http://ffmpeg.org/OnlineFilm.exe 主要执行程序FilesDownLoad.dll下载模块 新建   新建TS文件的索引文件,*.M3u8,怎么获取,参照“Ts文件说明”。M3U8文件如果是本地的文件,需要填写通用地址。…

    2022年7月18日
    58
  • 磁盘管理无法连接虚拟磁盘服务_diskpart虚拟磁盘服务错误

    磁盘管理无法连接虚拟磁盘服务_diskpart虚拟磁盘服务错误满意答案在ParallelsDesktop中,将新的空白虚拟硬盘添加到虚拟机配置后,对于安装在虚拟机中的操作系统来说它将不可见,直至将其初始化。初始化Windows中的新虚拟硬盘要初始化Windows虚拟机操作系统中的新虚拟硬盘,需要可用的磁盘管理工具。例如,在Windows7和WindowsXP中可以通过以下步骤访问该工具:·在Windows7中,点击“开始”>“控制面板”&…

    2022年9月21日
    3
  • mongodb access control is not enabled for the database

    mongodb access control is not enabled for the databasemongodb access control is not enabled for the database

    2022年4月25日
    67
  • 2020美赛A题解题方法

    2020美赛A题解题方法题目:问题A:向北移动全球海洋温度影响某些海洋生物的栖息地质量。当温度变化太大,它们无法继续繁荣时,这些物种就会迁移到其他更适合它们现在和未来生活和繁殖成功的栖息地。其中一个例子就是美国缅因州的龙虾种群,它们正缓慢地向北迁移到加拿大,那里的海洋温度较低,为它们提供了更合适的栖息地。这种地理种群的转移可能会严重影响依赖海洋生物稳定性的公司的生计。您的团队已被苏格兰北大西洋渔业管理协会聘请为顾问…

    2022年6月1日
    33
  • qtum量子链官网_币宽BitQuant量化交易系统

    qtum量子链官网_币宽BitQuant量化交易系统全球专业交易所Bithumb Global上线Qtum量子链,开启QTUM交易大赛

    2022年4月22日
    80
  • delphi中listview选择整行

    delphi中listview选择整行修改RowSelect属性为真

    2022年7月16日
    19

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号