赞
踩
分别生成和输入数据维度一致的全为0或全为1的内容
- import torch
-
- a = torch.tensor([[1,2,3],[4,5,6]])
-
- print(torch.zeros_like(a))
- print(torch.ones_like(a))
-
- >>>tensor([[0, 0, 0],
- [0, 0, 0]])
- tensor([[1, 1, 1],
- [1, 1, 1]])
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。