import torch
a = torch.ones([1,2])
print(a)
# tensor([[1., 1.]])
b = torch.ones([1,2])
print(b)
# tensor([[1., 1.]])
print(torch.cat([a,b],1))
# tensor([[1., 1., 1., 1.]])
torch.cat就是将a,b 按行放在一起,如果第二个参数是0,则按列放在一起。
博客介绍了torch.cat的使用方法,它可将张量进行拼接。当第二个参数为默认时,可将a、b按行拼接;若第二个参数设为0,则按列拼接。
import torch
a = torch.ones([1,2])
print(a)
# tensor([[1., 1.]])
b = torch.ones([1,2])
print(b)
# tensor([[1., 1.]])
print(torch.cat([a,b],1))
# tensor([[1., 1., 1., 1.]])
torch.cat就是将a,b 按行放在一起,如果第二个参数是0,则按列放在一起。
3万+
1134
5483

被折叠的 条评论
为什么被折叠?