PyTorch 加载模型出现 got an unexpected keyword argument ‘assign‘

PyTorch 加载模型出现 got an unexpected keyword argument ‘assign’

flyfish
错误提示

common\_base_model.py", line 433, in load
    model.load_state_dict(content["state_dict"], strict=True, assign=True)
TypeError: Module.load_state_dict() got an unexpected keyword argument 'assign'

查看PyTorch版本

import torch
print(torch.__version__) 
exit()

是2.0.0
查看源码
结果没有这个参数
https://github.com/pytorch/pytorch/blob/v2.0.0/torch/nn/modules/module.py

def load_state_dict(self, state_dict: Mapping[str, Any],
                    strict: bool = True):

看高版本的PyTorch版本有这个参数
https://github.com/pytorch/pytorch/blob/v2.3.0/torch/nn/modules/module.py

def load_state_dict(self, state_dict: Mapping[str, Any],
                    strict: bool = True, assign: bool = False):

如果使用assign这个参数需要升级下PyTorch版本

相关推荐

  1. PyTorch模型方法详解

    2024-06-08 00:30:04       57 阅读
  2. anylabeling 模型出错

    2024-06-08 00:30:04       69 阅读
  3. 深度学习-Pytorch如何保存和模型

    2024-06-08 00:30:04       63 阅读
  4. Pytorch 第一讲】 如何预训练模型

    2024-06-08 00:30:04       61 阅读
  5. Pytorch学习 day12(模型的保存和

    2024-06-08 00:30:04       41 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-08 00:30:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-08 00:30:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-06-08 00:30:04       82 阅读
  4. Python语言-面向对象

    2024-06-08 00:30:04       91 阅读

热门阅读

  1. Pytorch常用函数用法归纳:创建tensor张量

    2024-06-08 00:30:04       31 阅读
  2. Pytorch中Tensor的类型对应表

    2024-06-08 00:30:04       27 阅读
  3. 油封包装的关键注意事项

    2024-06-08 00:30:04       30 阅读
  4. 行列视(RCV)系统由哪几部分组成?

    2024-06-08 00:30:04       26 阅读
  5. Log4j日志级别介绍

    2024-06-08 00:30:04       28 阅读
  6. 数据结构:哈夫曼树及其哈夫曼编码

    2024-06-08 00:30:04       27 阅读