代码位置在:aten/src/Aten/native/cpu/UpSampleMoreKernel.cpp,关于bilinear的坐标计算过程:

template <typename scalar_t>
static inline scalar_t area_pixel_compute_source_index(scalar_t scale,int64_t dst_index,bool align_corners,bool cubic) {if (align_corners) {return scale * dst_index;            //half pixel为false} else {scalar_t src_idx = scale * (dst_index + 0.5) - 0.5;    //half pixel为true// [Note] Follow Opencv resize logic:// We allow negative src_idx here and later will use//   dx = src_idx - floorf(src_idx)// to compute the "distance"(which affects weights).// For linear modes, weight distribution doesn't matter// for negative indices as they use 2 pixels to interpolate.// For example, [-1, 0], they both use pixel 0 value so it// doesn't affect if we bound the src_idx to 0 or not.// TODO: Our current linear mode impls use unbound indices// where we should and then remove this cubic flag.// This matters in cubic mode, as we might need [-1, 0, 1, 2]// to interpolate and the weights can be affected.return (!cubic && src_idx < 0) ? scalar_t(0) : src_idx;}
}

关于nearest2d,可以看出计算中half_pixel应该是false

static inline int64_t nearest_neighbor_compute_source_index(const float scale,int64_t dst_index,int64_t input_size) {const int64_t src_index =std::min(static_cast<int64_t>(floorf(dst_index * scale)), input_size - 1);return src_index;
}

关于pytorch的upsample_bilinear2d的align_corners和half_pixel等参数确定相关推荐

  1. PyTorch | (4)神经网络模型搭建和参数优化

    PyTorch | (1)初识PyTorch PyTorch | (2)PyTorch 入门-张量 PyTorch | (3)Tensor及其基本操作 PyTorch | (4)神经网络模型搭建和参数 ...

  2. pytorch卷积操作nn.Conv中的groups参数用法解释

    MobileNetV1<MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications> ...

  3. pytorch:nn.ReLU(inplace=True) 中的参数 inplane 的作用

    pytorch 的激活函数nn.Relu() 有一个参数:inplace,其作用是:该nn.Relu() 函数计算得到的输出是否更新传入的输出. 正常情况下,一个卷积操作,首先经过卷积层,接着是正则化 ...

  4. Pytorch 中的数据类型 torch.utils.data.DataLoader 参数详解

    DataLoader是PyTorch中的一种数据类型,它定义了如何读取数据方式.详情也可参考本博主的另一篇关于torch.utils.data.DataLoader(https://blog.csdn ...

  5. Pytorch:使用官网提供数据集的相关参数设置,以CIFAR10为例进行说明

    文章目录 前言 一.Dataset 定义-组成 分类 二.获取数据集 1.参数说明 2.相关Demo 前言 本文记录笔者关于Dataset的相关学习记录,以Pytorch官网文档为主进行学习 一.Da ...

  6. pytorch加载预训练 加载部分参数

    最简单的: state_dict = torch.load(weight_path)    self.load_state_dict(state_dict,strict=False) 加载cpu: m ...

  7. pytorch加载之前训练模型中的部分参数以及冻结部分参数(实测,自己实际项目代码中的)

    我的需求是,由于我在不停的尝试各种模型,导致模型木块一直会变.如果每次重复重新开始训练要花费大把时间. 我之前运行的模型 ResNet ->                            ...

  8. 【pytorch】Module.parameters()函数实现与网络参数管理

    我们知道可以通过Module.parameters()获取网络的参数,那这个是如何实现的呢?我先直接看看函数的代码实现: def parameters(self):r""" ...

  9. pytorch系列 -- 9 pytorch nn.init 中实现的初始化函数 uniform, normal, const, Xavier, He initialization...

    本文内容: 1. Xavier 初始化 2. nn.init 中各种初始化函数 3. He 初始化 torch.init https://pytorch.org/docs/stable/nn.html ...

最新文章

  1. MegEngine推理性能优化
  2. DRF序列化和反序列化
  3. switch语句能否作用在byte上,能否作用在long上,能否作用在String上?
  4. linux /etc/profile和/etc/bashrc
  5. 趣谈网络协议笔记-二(第十八讲)
  6. 关于大型asp.net 应用系统的架构 —— 如何做到高性能高可伸缩性[转]
  7. position:relative 与 position:absolute
  8. 问题 C: 【例2-3】围圈报数
  9. Python | Socket01 - 创建一个TCP服务器(阻塞+单线程),将TCP客户端发过来的字符串原路返回
  10. vue 自定义组件 v-model
  11. lt;SCRIPT src=quot;../scripts/LoadWebOffice.jsquot;gt;lt;/SCRIPTgt;
  12. hello March
  13. linux命令行关机 密码,[ Linux 基本命令 001 ] 登陆,登出,重启,关机
  14. 二叉树叶子结点个数统计
  15. stm32 带通滤波器_PCB设计中建立带通滤波器波特图
  16. 有哪些资本运作的经典案例?
  17. java0.632数据类型_Object-c提供基本数据类型
  18. python 矩阵化为最简阶梯型
  19. 955 不加班的公司名单:955.WLB
  20. 超详细|算法岗学习路线大总结

热门文章

  1. MySql插入语句时报错,错误代码1062
  2. 小偷程序,专盗别人的网页内容
  3. UnityShader 曲面细分着色器 生成地形 高度贴图
  4. 《缠中说禅108课》89:中阴阶段的具体分析
  5. 涨知识!三山五岳你可能耳熟能详,那五湖四海你知道是哪里吗?
  6. 在谷歌浏览器Chrome中写的静态网页的<div class=“ad“>不显示,但把它放到别的浏览器中打开都能正常显示。
  7. 关于计算机的英语辩论,英语辩论题目,英语辩论题目computer!
  8. NSLog日志输出不全问题分析与解决方案
  9. 最老程序员创业札记:全文检索、数据挖掘、推荐引擎应用13
  10. 我有300万存支付宝的余额宝,可以实现财富自由吗?