in utils/data_loader.py [0:0]
def collate_fn(data):
""" Creates mini-batch tensors from the list of tuples (images, poses) """
data.sort(key=lambda x: len(x[1]), reverse=True)
images, poses, homography, poses2 = zip(*data)
images = torch.stack(images, 0)
lengths = [len(pose) for pose in poses]
targets = torch.zeros(len(poses), max(lengths)).long()
for i, pose in enumerate(poses):
end = lengths[i]
targets[i, :end] = pose[:end]
homography = torch.stack(homography, 0)
poses2 = torch.stack(poses2, 0)
return images, targets, homography, poses2, lengths