![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch学习
文章平均质量分 61
杨杨
这个作者很懒,什么都没留下…
展开
-
torch版本不一致,网络前向导致网络输出维度不一致问题
在torch1.7下,偶然发现使用ResNet框架,在前向的时候,最后一层总是未被使用。使用相同的测试代码(有兴趣可以自己复制测试代码到相应环境下测试):import torchimport torch.nn as nnimport torchvisioninputVar = torch.randn(1, 3, 224, 224)model = torchvision.models.resnet50(pretrained=True)num_ftrs = model.fc.in_features原创 2021-10-26 11:14:59 · 870 阅读 · 0 评论 -
pytorch模型保存与加载以及常见问题
一. 模型保存与加载#多gpuimport osos.environ['CUDA_VISIBLE_DEVICES'] = '1,2,3,4' #choosemodel = TheModelClass(*args, **kwargs)model = torch.nn.DataParallel(model).cuda()#加载与训练模型 file.pth.tarcheckpoint =...原创 2019-04-04 12:15:48 · 7046 阅读 · 4 评论 -
pytorch中的Datasets&DataLoader&datasets.ImageFolder相关问题
一.自定义Datasetsclass CustomDataset(data.Dataset):#需要继承data.Dataset def __init__(self): # TODO # 1. Initialize file path or list of file names. def __getitem__(self, index): ...原创 2019-04-01 18:50:26 · 2612 阅读 · 0 评论