当前位置:首页 » 《我的小黑屋》 » 正文

深入浅出Pytorch函数——torch.zeros

2 人参与  2024年04月13日 11:20  分类 : 《我的小黑屋》  评论

点击全文阅读


分类目录:《深入浅出Pytorch函数》总目录
相关文章:
· 深入浅出Pytorch函数——torch.Tensor
· 深入浅出Pytorch函数——torch.ones
· 深入浅出Pytorch函数——torch.zeros
· 深入浅出Pytorch函数——torch.full
· 深入浅出Pytorch函数——torch.ones_like
· 深入浅出Pytorch函数——torch.zeros_like
· 深入浅出Pytorch函数——torch.full_like


语法
torch.zeros(*size, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor
参数
size:大小,定义输出张量形状的整数序列。可以是可变数量的参数或集合,如:列表或元组。out:[可选,Tensor] 输出张量dtype:[可选,torch.dtype] 返回张量的所需数据类型。如果为None,则使用全局默认值(参考torch.set_default_tensor_type())。layout:[可选,torch.layout] 返回张量的期望内存布局形式,默认为torch.strideddevice:返回张量的期望计算设备。如果为None,使用当前的设备(参考torch.set_default_tensor_type()),设备将CPU用于CPU张量类型,将CUDA设备用于CUDA张量类型。requires_grad:[可选,bool] 是否需要自动微分,默认为False
返回值

返回一个每个元素都是0、形状为size、数据类型为dtype的Tensor。

实例
>>> torch.zeros(2, 3)tensor([[ 0.,  0.,  0.],        [ 0.,  0.,  0.]])>>> torch.zeros(5)tensor([ 0.,  0.,  0.,  0.,  0.])

点击全文阅读


本文链接:http://zhangshiyu.com/post/94684.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1