花了半天终于解决这个问题了,
Traceback (most recent call last):File "test_video.py", line 105, in <module>img_feature_dim=args.img_feature_dim, print_spec=False)File "/data2/zcq1/TRN-pytorch/models.py", line 43, in __init__self._prepare_base_model(base_model)File "/data2/zcq1/TRN-pytorch/models.py", line 108, in _prepare_base_modelself.base_model = getattr(model_zoo, base_model)()File "/data2/zcq1/TRN-pytorch/model_zoo/bninception/pytorch_load.py", line 38, in __init__self.load_state_dict(torch.utils.model_zoo.load_url(weight_url, model_dir='/data2/zcq1/TRN-pytorch/model_zoo'))File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 847, in load_state_dictself.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for BNInception:size mismatch for conv1_7x7_s2_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for conv1_7x7_s2_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for conv1_7x7_s2_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for conv1_7x7_s2_bn.running_var: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for conv2_3x3_reduce_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for conv2_3x3_reduce_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for conv2_3x3_reduce_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for conv2_3x3_reduce_bn.running_var: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for conv2_3x3_bn.weight: copying a param with shape torch.Size([1, 192]) from checkpoint, the shape in current model is torch.Size([192]).size mismatch for conv2_3x3_bn.bias: copying a param with shape torch.Size([1, 192]) from checkpoint, the shape in current model is torch.Size([192]).size mismatch for conv2_3x3_bn.running_mean: copying a param with shape torch.Size([1, 192]) from checkpoint, the shape in current model is torch.Size([192]).size mismatch for conv2_3x3_bn.running_var: copying a param with shape torch.Size([1, 192]) from checkpoint, the shape in current model is torch.Size([192]).size mismatch for inception_3a_1x1_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_1x1_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_1x1_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_1x1_bn.running_var: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_3x3_reduce_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_3x3_reduce_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_3x3_reduce_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_3x3_reduce_bn.running_var: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_3x3_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_3x3_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_3x3_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_3x3_bn.running_var: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_double_3x3_reduce_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).size mismatch for inception_3a_double_3x3_reduce_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).解决前的代码是这样的:
self.load_state_dict(torch.utils.model_zoo.load_url(weight_url, model_dir='./TRN-pytorch-master/model_zoo'))解决后:
model_BNInception = torch.utils.model_zoo.load_url(weight_url, model_dir='./TRN-pytorch-master/model_zoo')for name, weights in model_BNInception.items():# print(name, weights.size())  可以查看模型中的模型名字和权重维度if len(weights.size()) == 2: #判断需要修改维度的条件model_BNInception[name] = weights.squeeze(0)  #去掉维度0,把(1,128)转为(128)self.load_state_dict(model_BNInception)终于解决了,希望别人不要像我一样再浪费时间慢慢解决这个问题,特此共享一下解决方法

RuntimeError: Error(s) in loading state_dict for BNInception:size mismatch for相关推荐

  1. Error(s) in loading state_dict for ResNet 问题解决

    当使用如下命令加载模型的时候,会报错,没有一些 keys: model.load_state_dict(model_zoo.load_url(model_urls['resnet101'])) Run ...

  2. Error(s) in loading state_dict for ModelMain

    原代码: net = ModelMain(config, is_training=is_training) net.train(is_training) net = nn.DataParallel(n ...

  3. Error(s) in loading state_dict

    这个错误是因为model.load中的model的问题. 你下载到了别人的模型参数文件,但是这个model你必须先按照别人的代码中那个model构造,而不能是你的model. 也就是说,单单下载别人的 ...

  4. 测试模型是出现:RuntimeErrorError(s) in loading state_dict for MIMO-UNet

    测试模型是出现:RuntimeError:Error(s) in loading state_dict for MIMO-UNet 在测试已经训练好的模型时,一直出现RuntimeError的错误,结 ...

  5. RuntimeError: Error occured during execution of the processing block! See the log for more info

    Intel Realsense报错:RuntimeError: Error occured during execution of the processing block! See the log ...

  6. 【已解决】Error occurred during loading data. Trying to use cache server_Python系列学习笔记

    报错: Error occurred during loading data. Trying to use cache server Error occurred during loading dat ...

  7. ERROR 3948 (42000): Loading local data is disabled问题解决

    服务器版本: Server version: 8.0.20-0ubuntu0.19.10.1 (Ubuntu) 完整报错如下: ERROR 3948 (42000): Loading local da ...

  8. mongodb报错 An error occurred while loading navigation: topology was destroyed

    情况描述,关了电脑,第二天查询数据,报错An error occurred while loading navigation: topology was destroyed 我的数据库连接代码如下: ...

  9. ubuntu开机出现错误“Error found when loading /root/.profile”解决

    在刚修改完root权限自动登录后,发现开机出现以下提示: Error found when loading /root/.profile stdin:is not a tty ============ ...

  10. 最近项目开发再一次遇到了启动idea报错:Plugin Error Problems found loading plugins: Plugin “GlassFish Integration“ was

    最近项目开发再一次遇到了启动idea报错:Plugin Error Problems found loading plugins: Plugin "GlassFish Integration ...

最新文章

  1. 模拟系统照相机图片裁剪的功能
  2. 创建即时通信服务器的工具 openfire 简介
  3. python3 编写守护进程程序思路
  4. 第二章 GuassDB 数据库基础知识
  5. 【摩天好课推荐】2.4 Python代码常见的逻辑结构
  6. 中国人工智能学会通讯——神经环路研究最新进展及对类脑计算的启示 1.复杂科学...
  7. Linux 常用开关机以及7个启动级别
  8. tidyverse —— forcats包
  9. php7 ob get contents,关于ob_get_contents(),ob_end_clean(),ob_start(),的具体用法详解
  10. 通过JLINK下载程序(附JLINK驱动)
  11. 如何下载Django 离线文档?
  12. axios 最详细封装
  13. 别着急抢iPhone 13了!拍照有马赛克,苹果确认部分iPhone13存在bug
  14. Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's ro
  15. Kali忘记密码的重置方法
  16. 如何压缩图片到500KB?怎么压缩图片到指定大小?
  17. 软件工程毕业设计课题(21)基于JAVA毕业设计电子书小说网站系统毕设作品项目
  18. 以YOLOv5为基准实现布匹缺陷检测(Fabric Defect Detection)
  19. tpc-e mysql_mysql评测工具TPC-C使用
  20. Qt如何支持高分辨率屏幕(高分屏)

热门文章

  1. 由于系统错误 1114:动态连接库(DLL)初始化例程失败。(MySQL ODBC 5.3 Unicode Driver,c:\Program Files(x86)\MySQL\Connector
  2. oracle的dmp文件导入mysql_Oracle 数据库导入导出 dmp文件
  3. html640设计稿,为什么写移动端的ui给的640设计稿的宽度,在写html的时候要除以2才正好。...
  4. PHP获取MP3时长类
  5. 如何批量实现通过MP3标题重命名文件名
  6. rac 配置oracle互信,Oracle19C RAC 用户互信问题处理
  7. viper4android fx 驱动,ViPER4Android FX 音效驱动社区版安
  8. ViPER4Android FX 2.5,利用ViPER4Android FX音效驱动提升耳机音质
  9. quartus中与modelsim进行联合仿真出现错误error:(vopt-13130)failed to find design unit****
  10. 网络广告计费的三种形式:CPC、CPM、CPA