使用()连接张量时,出现错误如下:
TypeError: cat() received an invalid combination of arguments - got (Tensor, Tensor, dim=int), but expected one of:
- (tuple of Tensors tensors, name dim, *, Tensor out)
- (tuple of Tensors tensors, int dim, *, Tensor out)
是非常简单的一个报错,()和()接受张量的组合,即tensors;下面还原了错误用法。
a = (1,128,128,dtype=float)
b = (1,128,128,dtype=float)
c = (a,b,dim=0)
print(())
将ab整合为元组,拿括号括起来即可解决问题。
同样的错误操作下,()的报错如下:
TypeError: stack(): argument ‘tensors’ (position 1) must be tuple of Tensors, not Tensor
将输入张量用括号括起来解决问题。