TypeError: linear(): argument 'input' (position 1) must be Tensor, not str

在使用hugging fice加载预训练bert的时候,出现这个问题,原来是这样写的:

self.bert = BertModel.from_pretrained(pretrained_model_path, output_hidden_states=True, output_attentions=True, return_dict=True)

将 return_dict 设置为 False 即可

self.bert = BertModel.from_pretrained(pretrained_model_path, output_hidden_states=True, output_attentions=True, return_dict=False)

参考:https://blog.csdn.net/qsx123432/article/details/123984811

linear(): argument ‘input‘ (position 1) must be Tensor, not str相关推荐

  1. TypeError系列之:TypeError: conv2d(): argument 'input' (position 1) must be Tensor, not NoneType

    这里出现类似错误往往是因为,conv2d()函数的第一个参数,需要时一个tensor行的数据,然而却赋值成了not后给的类型. 我出现问题的原因是,中间有一个函数缺少返回值,因此会造成NoneType ...

  2. argument ‘input‘ (position 1) must be Tensor, not XX

    这里:numpy 和 tensor数据相互转换的方法: 1.numpy->tensor data = torch.tensor(data) 2.tensor->numpy 非训练数据(训练 ...

  3. input(position 1) must be Tensor, not NoneType

    https://blog.csdn.net/qq_41368074/article/details/105560274?utm_medium=distribute.pc_relevant.none-t ...

  4. pytorch view(): argument 'size' (position 1) must be tuple of ints, not Tensor

    view(): argument 'size' (position 1) must be tuple of ints, not Tensor pytorch的view函数参数不能是tensor,解决方 ...

  5. {TypeError}clamp(): argument 'min' must be Number, not Tensor

    {TypeError}clamp(): argument 'min' must be Number, not Tensor x1是二维数组, xx1 = x1[order[1:]].clamp(min ...

  6. errors_impl.InvalidArgumentError: Input to reshape is a tensor

    errors_impl.InvalidArgumentError: Input to reshape is a tensor InvalidArgumentError (see above for t ...

  7. pytorch torch.norm(input, p=2) → float、torch.norm(input, p, dim, out=None) → Tensor(求范数)

    torch.norm 用法1: torch.norm(input, p=2) → float 返回输入张量input 的p 范数. 参数: input (Tensor) – 输入张量 p (float ...

  8. 2021.08.25学习内容torch.clamp(input, min, max, out=None) → Tensor,torch.mm(matrix multiply)

    学习pytorch时,看到了mm和clamp,不甚理解,其他地方也看到过,所以具体了解一下 前向传递:计算预测yh = x.mm(w1)h_relu = h.clamp(min=0) 把 h 张量的最 ...

  9. 【tensorflow】Input to reshape is a tensor with xxx values, but the requested shape requires a multipl

    今天写了一个简单的3DCNN,结果在跑的时候出现一个问题, tensorflow.python.framework.errors.InvalidArgumentError: Input to resh ...

最新文章

  1. 智源新闻 | 麻省理工学院教授Max Tegmark报告交流会在北京举行
  2. 软文的作用真的有那么神奇吗?
  3. Spring 源码分析 spring-core
  4. 2012年第一个工作日
  5. yolo算法_不到2MB,超轻YOLO算法!准确率接近YOLOv3,速度快上45%
  6. 中式装修怎么做,有哪些注意事项?
  7. 使用浏览器地址栏调用CXF Webservice的写法
  8. java类型转换的要求_java数据类型04_基本数据类型转换
  9. Android的cangoback方法,Android应用开发Android8.0 WebView返回上一层失效(canGoBack返回false问题)解决办法...
  10. Chrome 谷歌浏览器将整个网页保存为图片
  11. sloth(标点工具)使用说明
  12. [6.15] 心态 信念
  13. html页面ie不显示图片,IE浏览器网页不显示图片如何解决?解决方法介绍
  14. 零基础学FPGA(四):IP是什么东西(什么是软核,硬核)
  15. 直播行业的梦幻泡影:主播们的数据人生
  16. 浏览器同源政策之ajax请求不能发送
  17. 阳性,阴性,假阳性,假阴性,敏感度,特异性
  18. SpringBoot+Vue实现前后端分离的校园外卖配送系统
  19. 【软考】【系统架构设计师】2021上午真题及答案
  20. ItunesConnect:苹果内购项目元数据缺失

热门文章

  1. 58元/月,支付宝的付费选股指标「神奇九转」有用吗?
  2. 解决git:'instaweb' 不是一个 git 命令。参见 'git --help'。问题
  3. UE4 初始化全局着色器库所需的游戏文件缺失
  4. 首选项配置+Eslint+prettier+Vetur
  5. 智能锁浪潮的来袭你真的准备好了吗?
  6. MapReduce论文阅读思维导图
  7. leetcode 弗洛伊德算法 1462. 课程表 IV
  8. Photoshop 技能大全(包括九大类技能)
  9. Dell INSPIRON N4050 XP系统安装
  10. MQL5 向导:如何教导 EA 以任意价格建立挂单