import torch
T = torch.tensor([1,2,3])
print("T's shape: ",T.shape,"\n")
print("T: ",T,"\n")
print("T.repeat(2,2): \n", T.repeat(2,2),"\n")
print("T.repeat(1,5): \n", T.repeat(1,5),"\n")
输出:
关注:T.repeat(1,5)
T's shape: torch.Size([3])
T: tensor([1, 2, 3])
T.repeat(2,2):
tensor([[1, 2, 3, 1, 2, 3],
[1, 2, 3, 1, 2, 3]])
T.repeat(1,5):
tensor([[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]])
注意:
gt_depth.reshape(-1, 1)
gt_depth = gt_depth.repeat(1, N_samples)
import torch
N_samples = 4
gt_depth = torch.tensor([[1,2,3],[4,5,6]])
print(gt_depth.shape)
print(gt_depth,"\n")
gt_depth = gt_depth.reshape(-1, 1)
print(gt_depth.shape)
print(gt_depth,"\n")
gt_depth = gt_depth.repeat(1, N_samples)
print(gt_depth.shape)
print(gt_depth,"\n")
torch.Size([2, 3])
tensor([[1, 2, 3],
[4, 5, 6]])
torch.Size([6, 1])
tensor([[1],
[2],
[3],
[4],
[5],
[6]])
torch.Size([6, 4])
tensor([[1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3],
[4, 4, 4, 4],
[5, 5, 5, 5],
[6, 6, 6, 6]])