数据加载方法
DataLoader参数pin_memory
Dataloader的pin_memory设置为True可以将Tensor放入到内存的锁页区,加快训练速度。
非阻塞(Non-Blocking)
target = target.cuda(non_blocking=True)
torchvision-transform
https://pytorch-cn.readthedocs.io/zh/latest/torchvision/torchvision-transform/
def transf(img):
trans1 = transforms.Resize((640*3, 360*3))
trans2 = transforms.ToTensor()
img1 = trans1(img)
return trans2(img1)
本文介绍了使用PyTorch进行高效训练的一些实用技巧,包括如何利用Dataloader的pin_memory选项加速数据加载,采用非阻塞方式转移数据到GPU,以及使用torchvision库中的transform进行图像预处理,并探讨了checkpoint技术在节省内存方面的应用。
988

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



