当前位置: 首页 > news >正文

深入浅出Pytorch函数——torch.nn.init.constant_

分类目录:《深入浅出Pytorch函数》总目录
相关文章:
· 深入浅出Pytorch函数——torch.nn.init.calculate_gain
· 深入浅出Pytorch函数——torch.nn.init.uniform_
· 深入浅出Pytorch函数——torch.nn.init.normal_
· 深入浅出Pytorch函数——torch.nn.init.constant_
· 深入浅出Pytorch函数——torch.nn.init.ones_
· 深入浅出Pytorch函数——torch.nn.init.zeros_
· 深入浅出Pytorch函数——torch.nn.init.eye_
· 深入浅出Pytorch函数——torch.nn.init.dirac_
· 深入浅出Pytorch函数——torch.nn.init.xavier_uniform_
· 深入浅出Pytorch函数——torch.nn.init.xavier_normal_
· 深入浅出Pytorch函数——torch.nn.init.kaiming_uniform_
· 深入浅出Pytorch函数——torch.nn.init.kaiming_normal_
· 深入浅出Pytorch函数——torch.nn.init.trunc_normal_
· 深入浅出Pytorch函数——torch.nn.init.orthogonal_
· 深入浅出Pytorch函数——torch.nn.init.sparse_


torch.nn.init模块中的所有函数都用于初始化神经网络参数,因此它们都在torc.no_grad()模式下运行,autograd不会将其考虑在内。

该函数用val的值填充输入的张量或变量

语法

torch.nn.init.constant_(tensor, val)

参数

  • tensor:[Tensor] 一个 N N N维张量torch.Tensor
  • val:[float] 用来填充张量的值

返回值

一个torch.Tensor且参数tensor也会更新

实例

w = torch.empty(3, 5)
nn.init.constant_(w, 0.3)

函数实现

def constant_(tensor: Tensor, val: float) -> Tensor:r"""Fills the input Tensor with the value :math:`\text{val}`.Args:tensor: an n-dimensional `torch.Tensor`val: the value to fill the tensor withExamples:>>> w = torch.empty(3, 5)>>> nn.init.constant_(w, 0.3)"""if torch.overrides.has_torch_function_variadic(tensor):return torch.overrides.handle_torch_function(constant_, (tensor,), tensor=tensor, val=val)return _no_grad_fill_(tensor, val)
http://www.lryc.cn/news/130901.html

相关文章:

  • centos mysql8解决Access denied for user ‘root‘@‘localhost‘ (using password: YES)
  • Docker实战:Docker常用命令
  • 基于51单片机直流电机转速数码管显示控制系统
  • 小程序商品如何指定打印机
  • LLaMA-7B微调记录
  • 域名子目录发布问题(nginx、vue-element-admin、uni-app)
  • 【环境配置】Windows 10 安装 PyTorch 开发环境,以及验证 YOLOv8
  • 数学建模之“层次分析法”原理和代码详解
  • 使用IText导出复杂pdf
  • 多线程并发服务器(TCP)
  • uni-app的Vue.js实现微信小程序的紧急事件登记页面功能
  • 面试题 17.16.按摩师
  • vscode里配置C#环境并运行.cs文件
  • uniapp配置添加阿里巴巴图标icon流程步骤
  • 大模型基础02:GPT家族与提示学习
  • 算法基础课——基础算法(模板整理)
  • 如何解决使用npm出现Cannot find module ‘XXX\node_modules\npm\bin\npm-cli.js’错误
  • 【华为认证数通高级证书实验-分享篇2】
  • ui设计需要学编程吗难不难学习 优漫动游
  • 什么是线程优先级?Java中的线程优先级是如何定义和使用的?
  • 无涯教程-TensorFlow - XOR实现
  • 计算机组成与设计 Patterson Hennessy 笔记(二)MIPS 指令集
  • 【设计模式】模板方法模式(Template Method Pattern)
  • 【潮州饶平】联想 IBM x3850 x6 io主板故障 服务器维修
  • 【AIGC】 国内版聊天GPT
  • 如何在Vue中进行单元测试?什么是Vue的模块化开发?
  • Matlab编程示例3:Matlab求二次积分的编程示例
  • 【Linux】线程同步和死锁
  • Matplotlib数据可视化(二)
  • 图像去雨-雨线清除-图像处理-(计算机作业附代码)