- 博客(3)
- 收藏
- 关注
原创 RuntimeError: Module backward hook for grad_input is called before the grad_output one. 解决方法
net.load_state_dict(torch.load("./transfer-learning-resnet.pth", map_location=device)) # 载入训练的resnet模型权重,你将训练的模型权重放到当前文件夹下即可。#这个下面放置你网络的代码,因为载入权重的时候需要读取网络代码,这里我建议直接从自己的训练代码中原封不动的复制过来即可,我这里因为跑代码使用的是Resnet,所以这里将resent的网络复制到这里即可。这么做的好处是能够在top1上提升大概0.5%的准确率。
2023-04-02 17:37:45
428
2
转载 python中的os.path.dirname(__file__)的使用(转载)
原文链接:https://blog.youkuaiyun.com/u011760056/article/details/46969883os.path.dirname(__file__)返回脚本的路径,但是需要注意一下几点:1、必须是实际存在的.py文件,如果在命令行执行,则会引发异常NameError: name '__file__' is not defined2、在运行的时候如果输入完整的执行的路径,则返回.py文件的全路径如:python c:/test/test.py 则返回路径 c:/tes
2021-11-09 15:44:40
1229
原创 VIT训练
加载imagenet预训练模型:首先需要安装timm库:pip install timmtimm库使用的话参考https://rwightman.github.io/pytorch-image-models/这里加载了输入图像大小为224*224,patch大小为16*16的vit模型from timm import create_model as creatmodel = creat('vit_base_patch16_224', pretrained=True, num_clas
2021-09-17 11:39:37
15897
6
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人