当前位置:   article > 正文

orch.tensor的fill_(value)_torch.tensor.fill

torch.tensor.fill

>>> import torch
>>> torch.manual_seed(seed=20200910)
<torch._C.Generator object at 0x000001FB002DD330>
>>> a = torch.randn(3,4)
>>> b = a
>>> a
tensor([[ 0.2824, -0.3715,  0.9088, -1.7601],
        [-0.1806,  2.0937,  1.0406, -1.7651],
        [ 1.1216,  0.8440,  0.1783,  0.6859]])
>>> b
tensor([[ 0.2824, -0.3715,  0.9088, -1.7601],
        [-0.1806,  2.0937,  1.0406, -1.7651],
        [ 1.1216,  0.8440,  0.1783,  0.6859]])
>>> a.fill_(20200910.0)
tensor([[20200910., 20200910., 20200910., 20200910.],
        [20200910., 20200910., 20200910., 20200910.],
        [20200910., 20200910., 20200910., 20200910.]])
>>> a
tensor([[20200910., 20200910., 20200910., 20200910.],
        [20200910., 20200910., 20200910., 20200910.],
        [20200910., 20200910., 20200910., 20200910.]])
>>> b
tensor([[20200910., 20200910., 20200910., 20200910.],
        [20200910., 20200910., 20200910., 20200910.],
        [20200910., 20200910., 20200910., 20200910.]])
>>>
>>>
>>>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/765785
推荐阅读
相关标签
  

闽ICP备14008679号