一,张量的拼接
我举两个例子来分别说明下:
flag = True
if flag:
t = torch.ones((2,3))
t_0 = torch.cat([t,t],dim=0)
t_1 = torch.cat([t,t],dim=1)
print("t_0:{} shape:{}\nt_1:{} shape:{}".format(t_0,t_0.shape,t_1,t_1.shape))
运行处的结果为:
这一个很好理解。
第二个例子:
flag = True
if flag:
t = torch.ones((2,3))
t_stack = torch.stack([t,t],dim=2