一些coding过程中遇到的问题(持续更新)

本文汇总了PyTorch框架在使用过程中遇到的各种常见问题及其解决方案,包括内存溢出、模型保存与加载、错误信息解读及代码调试技巧。同时,介绍了如何调整学习率以优化模型训练,并解释了pth文件的作用。

解决targets.cuda(async=True)
https://blog.youkuaiyun.com/zyl615110/article/details/91456106
把async=True改为non_blocking=True

解决No module named progress
pip install progress

runtime error: cuda out of memory
修改batchsize大小,我之前居然用了256,服了自己><,现在用64

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python
https://blog.youkuaiyun.com/qq_35523233/article/details/88046064

volatile was removed
去掉‘volatile = True’

保存模型并使用与训练模型
https://blog.youkuaiyun.com/u011276025/article/details/78507950
https://www.pytorchtutorial.com/pytorch-note5-save-and-restore-models/
https://blog.youkuaiyun.com/u014380165/article/details/79119664

finetune是什么?
fine tune就是用别人训练好的模型,加上我们自己的数据,来训练新的模型。

解压checkpoint.pth.tar时,根据
https://www.cnblogs.com/manong--/p/8012324.html
用命令tar -xvf filename.tar,但是
报错:
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
解决:
索性把文件名改了,去掉.tar,改为checkpoint.pth
错误原因:
根据报错原因,可以知道这个被压缩的文件其实不是tar,因此只是文件名错了。

linux关于去到哪个目录:
https://blog.youkuaiyun.com/l_liangkk/article/details/78729059
(cd…好像不行???)

linux绝对路径,相对路径
https://blog.youkuaiyun.com/jingtian678/article/details/78329356

.pth文件是什么
https://blog.youkuaiyun.com/weixin_41797117/article/details/80054151

学习率
当学习率设置的过小时,收敛过程将变得十分缓慢。而当学习率设置的过大时,梯度可能会在最小值附近来回震荡,甚至可能无法收敛。

我的数据集里面只有3类,但是使用resnet时,输入一张图后得到的outputs的shape是(1,1000)。这是因为resnet的结构——最后一层是FC1000。然后,我的outputs第3维后的数值都接近于0页印证了这点。
如果这时想得到模型判断出来的那个类别,就要用argmax函数,获取最大值对应的索引值。

linux下解压zip文件
先转到合适的目录,再写命令unzip filename.zip
https://www.cnblogs.com/zdz8207/p/3765604.html

linux下建立软连接
ln -s destfile/directory softlink #建立软连接
https://blog.youkuaiyun.com/yasaken/article/details/7292186

linux下查找显卡型号
https://blog.youkuaiyun.com/maizousidemao/article/details/88821949

VideoCapture()参数
0-电脑内置摄像头
1-第二个摄像头
https://blog.youkuaiyun.com/Zhou_yongzhe/article/details/80310537
https://www.jianshu.com/p/2b79012c0228

os.chdir(path)
用于改变当前工作目录到指定的路径。

python的glob包
用于查找所有符合条件的文件,
可以用来批量处理文件。
https://blog.youkuaiyun.com/u010472607/article/details/76857493/

no module named easydict
pip install easydict

No module named ‘model.utils.cython_bbox’

faster-rcnn运行中遇到的问题
linux下查看ubuntu版本
sudo lsb_release -a

查看python版本
python -V

查看cuda版本
nvcc -V

查看gpu信息
lspci | grep -i vga

cuda
https://blog.youkuaiyun.com/ly7969/article/details/84982373

ubuntu16.04安装gcc7.4
https://www.cnblogs.com/shuazi/p/10688992.html

RemoveError: ‘setuptools’ is a dependency of conda and cannot be removed from
conda’s operating environment.
https://www.cnblogs.com/hellojiaojiao/p/10872421.html

配置环境
export cuda path to environment
https://blog.youkuaiyun.com/hizengbiao/article/details/88625399

linux下批量修改文件里的内容
https://blog.youkuaiyun.com/qq_21101587/article/details/81203767

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值