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)



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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 设计模式之六大设计原则[通俗易懂]

    设计模式之六大设计原则

  • Java标识符的命名规则[通俗易懂]

    Java标识符的命名规则[通俗易懂]Java语言中,为各种变量、方法和类等起的名字称为标识符Java标识符的命名规则:应以字母、下划线、美元符开头后跟字母、下划线、美元符或数字Java标识符大小写敏感,长度无限制1.java中能用作标识符的有:26个英文字母(大、小写),数字,下划线,美元符号$。但是不能以数字开头。2.类名首个字母必须大写,多个单词组成的,每个单词首字母都要大写。3.方法名一般首个字母小写(构造…

  • goland 激活码2021【永久激活】

    (goland 激活码2021)本文适用于JetBrains家族所有ide,包括IntelliJidea,phpstorm,webstorm,pycharm,datagrip等。https://javaforall.cn/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~V…

  • Determining IP information for eth0… failed; no link present.  Check cable?

    Determining IP information for eth0… failed; no link present.  Check cable?问题1:docker pull nginx 拉取失败问题2:Determining IP information for eth0… failed; no link present. Check cable?问题3:“VMware Network Adapter VMnet8”没有有效的 IP 配置问题4:没有开启VMware NAT service和VMware DHCP …

  • java executeupdate_执行完executeUpdate()方法…-体系课

    java executeupdate_执行完executeUpdate()方法…-体系课如题:Servlet代码如下:packagejdbcHomeWork;importjava.io.IOException;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.SQLException;importjavax.servlet.ServletException;importja…

    2022年10月20日
  • UE4 Slate四 SlateUI如何做动画「建议收藏」

    UE4 Slate四 SlateUI如何做动画「建议收藏」原创文章,转载请注明出处。点击观看上一篇《UE4Slate三SlateUI代码讲解》点击观看下一篇《UE4Slate五开篇》虚幻引擎SlateUI介绍1>前言2>SlateAnimation代码1>前言我们都知道在UMG里面如何创建一个UMG的动画,其实就是时间帧动画。那么在Slate纯手写的代码上如何做动画呢?2>SlateAnimation代码…

发表回复

您的电子邮箱地址不会被公开。

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