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

分类目录:《深入浅出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不会将其考虑在内。

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

语法

复制代码
torch.nn.init.ones_(tensor)

参数

  • tensor:[Tensor] 一个 N N N维张量torch.Tensor

返回值

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

实例

复制代码
w = torch.empty(3, 5)
nn.init.ones_(w)

函数实现

复制代码
def ones_(tensor: Tensor) -> Tensor:
    r"""Fills the input Tensor with the scalar value `1`.

    Args:
        tensor: an n-dimensional `torch.Tensor`

    Examples:
        >>> w = torch.empty(3, 5)
        >>> nn.init.ones_(w)
    """
    return _no_grad_fill_(tensor, 1.)
相关推荐
时见先生4 小时前
Python库和conda搭建虚拟环境
开发语言·人工智能·python·自然语言处理·conda
昨夜见军贴06166 小时前
IACheck AI审核在生产型企业质量控制记录中的实践探索——全面赋能有关物质研究合规升级
大数据·人工智能
智星云算力6 小时前
智星云镜像共享全流程指南,附避坑手册(新手必看)
人工智能
盖雅工场6 小时前
驱动千店销售转化提升10%:3C零售门店的人效优化实战方案
大数据·人工智能·零售·数字化管理·智能排班·零售排班
Loo国昌6 小时前
深入理解 FastAPI:Python高性能API框架的完整指南
开发语言·人工智能·后端·python·langchain·fastapi
发哥来了6 小时前
【AI视频创作】【评测】【核心能力与成本效益】
大数据·人工智能
醉舞经阁半卷书17 小时前
Python机器学习常用库快速精通
人工智能·python·深度学习·机器学习·数据挖掘·数据分析·scikit-learn
产品何同学8 小时前
在线问诊医疗APP如何设计?2套原型拆解与AI生成原型图实战
人工智能·产品经理·健康医疗·在线问诊·app原型·ai生成原型图·医疗app
星爷AG I8 小时前
9-14 知觉整合(AGI基础理论)
人工智能·agi
开源技术8 小时前
Violit: Streamlit杀手,无需全局刷新,构建AI面板
人工智能·python