这个函数主要是为了生成对角线全1,其余部分全0的二维数组
函数原型:
result = torch.eye(n,m=None,out=None)
参数解释:
n:行数
m:列数
out:输出类型
例:
c = torch.eye(3)
print(c)
print(type(c))
输出
tensor([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
<class 'torch.Tensor'>
这个函数主要是为了生成对角线全1,其余部分全0的二维数组
函数原型:
result = torch.eye(n,m=None,out=None)
参数解释:
n:行数
m:列数
out:输出类型
例:
c = torch.eye(3)
print(c)
print(type(c))
输出
tensor([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
<class 'torch.Tensor'>