pytorch报错:RuntimeError: CUDA error: device-side assert triggered
参数:unable to get repr for class 'torch.tensor'
错误定位:类别数目不对;
RuntimeError: Given groups=1, weight of size 40 3 3 3,
expected input[4, 300, 302, 5] to have 3 channels, but got 300 channels instead
问题描述:训练完第一个epoch后出现上述bug,
原因:验证阶段,图像数据输入维数存在问题,需要变换通道。
RuntimeError: Error(s) in loading state_dict for EfficientNet:
Missing key(s) in state_dict: "_conv_stem.weight", "_bn0.weight", "_bn0.bias", .... ,"_bn1.running_mean", "_bn1.running_var", "_fc.weight", "_fc.bias".
Unexpected key(s) in state_dict: "module._conv_stem.weight", "module._bn0.weight", "module._bn0.bias", ... ,"module._bn1.running_mean", "module._bn1.running_var", "module._bn1.num_batches_tracked", "module._fc.weight", "module._fc.bias".
原因:模型没有放到GPU上,就载入权重。
改正:模型初始化model = EfficientNet.from_name('efficientnet-b3', 102)
后面加:model = torch.nn.DataParallel(model).cuda()
Traceback (most recent call last)
TypeError: 'module' object is not callable
原因:库没有正确加载
Traceback (most recent call last):
TypeError: 'list' object is not callable
原因:代码中使用内置函数名或关键字定义了变量。
yolov5中的调用问题:
ModuleNotFoundError: No module named 'models'
原因:序列化问题
import os, sys
root_path = os.getcwd()
sys.path.insert(0, root_path + '/project/yolov5')
from project.yolov5.predict import detect
更多推荐
pytorch-buglist:
发布评论