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

这篇具有很好参考价值的文章主要介绍了深入浅出Pytorch函数——torch.zeros_like。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

分类目录:《深入浅出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


返回一个形状与input相同且值全为0的张量。torch.zeros_like(input)相当于torch.zeros(input.size, dtype=input.dtype,layout=input.layout,device=input.device)

语法
torch.zeros_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) → Tensor
参数
  • input:[Tensor] input向量的形状决定了输出向量的形状。
  • dtype:[可选,torch.dtype] 返回张量的所需数据类型。如果为None,则使用全局默认值(参考torch.set_default_tensor_type())。
  • layout:[可选,torch.layout] 返回张量的期望内存布局形式,默认为torch.strided
  • device:返回张量的期望计算设备。如果为None,使用当前的设备(参考torch.set_default_tensor_type()),设备将CPU用于CPU张量类型,将CUDA设备用于CUDA张量类型。
  • requires_grad:[可选,bool] 是否需要自动微分,默认为False
  • memory_format:[可选,torch.memory_format] 返回张量的所需内存格式,默认为torch.preserve_format
返回值

返回一个形状与input相同且值全为0的张量。文章来源地址https://www.toymoban.com/news/detail-446667.html

实例
>>> input = torch.empty(2, 3)
>>> torch.zeros_like(input)
tensor([[ 0.,  0.,  0.],
        [ 0.,  0.,  0.]])

到了这里,关于深入浅出Pytorch函数——torch.zeros_like的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 深入浅出Pytorch函数——torch.t

    分类目录:《深入浅出Pytorch函数》总目录 相关文章: · 深入浅出TensorFlow2函数——tf.transpose · 深入浅出Pytorch函数——torch.t · 深入浅出Pytorch函数——torch.transpose · 深入浅出PaddlePaddle函数——paddle.transpose 语法 参数 input : [Tensor] 输入的张量。 返回值 被转置的张量。 实例

    2024年02月11日
    浏览(36)
  • 深入浅出Pytorch函数——torch.ones

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

    2023年04月26日
    浏览(90)
  • 深入浅出Pytorch函数——torch.maximum

    分类目录:《深入浅出Pytorch函数》总目录 相关文章: · 深入浅出Pytorch函数——torch.max · 深入浅出Pytorch函数——torch.maximum 计算 input 和 other 的元素最大值。 语法 参数 input :[ Tensor ] 输入张量 other :[ Tensor ] 输入的第二个张量 实例

    2024年02月15日
    浏览(32)
  • 深入浅出Pytorch函数——torch.full

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

    2024年02月07日
    浏览(40)
  • 深入浅出Pytorch函数——torch.max

    分类目录:《深入浅出Pytorch函数》总目录 相关文章: · 深入浅出Pytorch函数——torch.max · 深入浅出Pytorch函数——torch.maximum torch.max 有三种输入形式,根据其输入形式及参数的不同有下列三种返回形式: torch.max(input) :返回输入张量所有元素的最大值。 torch.max(input, dim, keep

    2024年02月15日
    浏览(32)
  • 深入浅出Pytorch函数——torch.exp

    分类目录:《深入浅出Pytorch函数》总目录 相关文章: · 深入浅出TensorFlow2函数——tf.exp · 深入浅出TensorFlow2函数——tf.math.exp · 深入浅出Pytorch函数——torch.exp · 深入浅出PaddlePaddle函数——paddle.exp 对输入 input 逐元素进行以自然数 e e e 为底指数运算。 语法 参数 input :[ Te

    2024年02月11日
    浏览(32)
  • 深入浅出Pytorch函数——torch.squeeze

    分类目录:《深入浅出Pytorch函数》总目录 相关文章: · 深入浅出Pytorch函数——torch.squeeze · 深入浅出Pytorch函数——torch.unsqueeze 将输入张量形状为1的维度去除并返回。比如输入向量的形状为 A × 1 × B × 1 × C × 1 × D Atimes1times Btimes1times Ctimes1times D A × 1 × B × 1 × C × 1 ×

    2024年02月16日
    浏览(34)
  • 深入浅出Pytorch函数——torch.sum

    分类目录:《深入浅出Pytorch函数》总目录 相关文章: · 深入浅出TensorFlow2函数——tf.reduce_sum · 深入浅出TensorFlow2函数——tf.math.reduce_sum · 深入浅出Pytorch函数——torch.sum · 深入浅出PaddlePaddle函数——paddle.sum 语法 参数 input :[ Tensor ] 输入的张量。 dim :[可选, int / tuple ] 求和

    2024年02月04日
    浏览(57)
  • 深入浅出Pytorch函数——torch.arange

    分类目录:《深入浅出Pytorch函数》总目录 相关文章: · 深入浅出TensorFlow2函数——tf.range · 深入浅出Pytorch函数——torch.arange · 深入浅出PaddlePaddle函数——paddle.arange 语法 当 dtype 表示浮点类型时,为了避免浮点计算误差,建议给 end 加上一个极小值 epsilon ,使边界可以更加明

    2024年02月04日
    浏览(36)
  • 深入浅出PyTorch函数torch.rand与torch.randn

    torch.rand 和 torch.randn 都是PyTorch中用于生成随机张量的函数,但它们生成随机数的方式有所不同。 torch.rand 生成在区间 [0, 1) 内均匀分布的随机数。 size 参数是一个表示所需张量形状的元组或整数。可以生成任何形状的随机张量。 torch.randn 生成从标准正态分布(均值为0,标准

    2024年02月09日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包