Index out of range using input dim 2; input has only 2 dims

原文地址:https://blog.csdn.net/qq_31456593/article/details/89578018

这是因为crf层期望标签具有不同的形状。

通常,我们的标签的shape为(num_samples,max_length),但crf层需要的shape为(num_samples,max_length,1)。

解决方法:

将标签扩一维

y_train = np.expand_dims(y_train,2)

Index out of range using input dim 2; input has only 2 dims相关推荐

  1. ValueError: Index out of range using input dim 2; input has only 2 dims for 'crf_1/strided_slice' (o

    ValueError: Index out of range using input dim 2; input has only 2 dims for 'crf_1/strided_slice' (o ...

  2. torch.unsqueeze(input, dim)函数

    函数调用形式:torch.unsqueeze(input, dim) → Tensor 功能: 在指定位置 dim 插入一个大小为1的维度 input: old tensor dim: 插入维度的位置 ...

  3. torch.gather(input, dim, index, *, sparse_grad=False, out=None) → Tensor

    torch.gather(input, dim, index, *, sparse_grad=False, out=None) → Tensor 沿dim指定的轴聚集值. 对于三维张量,输出由以下公式 ...

  4. 爬虫时出现 IndexError: list index out of range 的原因

    爬虫时出现 IndexError: list index out of range 的原因有两种: 简单举例如下: 第一种情况: index越界 Alex = [1,2,3] Alex[1] 2 Al ...

  5. python list超出范围_错误:列表索引超出范围Python(Error: List Index out of Range Python)...

    错误:列表索引超出范围Python(Error: List Index out of Range Python) 我已经查看了所有错误以找到解决方案,但我找不到可行的解决方案! 我得到列表索引超出范围 ...

  6. java out of range_关于Parameter index out of range求解决办法

    程序: 提示参数越界,但我实在不知道我到底哪里越界了.明明该我那样写的嘛.求高手帮我看看, 现在我是弄得我有气无力了!要死了.在去死亡的路上等着你帮帮我! Document   : replyok C ...

  7. IndexError: list index out of range的解决办法

    IndexError: list index out of range的解决办法 列表的索引也就是他的元素的个数是没有你所想要找的元素位置,比如这个列表只有十个元素你要找第11个元素这个肯定找不到 解 ...

  8. python list越界原因(list assignment index out of range)

    分析: list assignment index out of range:列表超过限制 情况1:list[index]index超出范围 情况2:list是一个空的,没有一个元素,进行list[0 ...

  9. 很有必要看,这篇 解决 IndexError: list index out of range

    运行逻辑回归代码,遭遇bug: Traceback (most recent call last):File "D:/DTLFolder/paperTest/Paper_logistic r ...

最新文章

  1. 来个例子,彻底弄懂什么是 EM 算法
  2. 【入门基础】写给小白看的入门级 Java 基本语法
  3. 判断同构数 c语言,基于visual Studio2013解决C语言竞赛题之0413同构数
  4. python asyncio future_Python asyncio.isfuture方法代码示例
  5. web前端期末大作业--奥迪RS汽车主题官网设计(HTML+CSS+JavaScript)实现
  6. 2020快手移动游戏行业玩家数据价值报告
  7. Knockout事件传递参数的几种方式
  8. .net下调用WebService
  9. RedHat Linux 加入域
  10. Android-JNI开发系列《六》jni与java的交互
  11. RemoveDirectory 功能:删除文件夹
  12. MySQL-第六篇DML语句
  13. OpenWrt增加Led
  14. 小故事大道理:一把小椅子
  15. excel入门/常用的技巧
  16. 英飞凌TC397移植FreeRTOS
  17. 大学计算机专业清华,中国计算机专业最“牛”的4所大学,清华第1,当之无愧...
  18. 如何用Python 求函数 y = sinx 在区间[0, pi/2]上的弧长
  19. web前端人员自行切图教程
  20. windows使用教程大全

热门文章

  1. 微信文件传输助手网页版
  2. git amend如何撤销
  3. tab weui 页面切换_weui 多网页切换效果分析
  4. OSChina 周五乱弹 —— 夏日限定梦想
  5. 浅谈C/C++ 开发Excel插件之操作excel
  6. 数据结构:通过hash表建立一个宝可梦图鉴管理系统
  7. 【Python】经典问题创建一个矩形类,定义方法 属性 初始化
  8. Android 面试系列(一)Android 基础
  9. w10不能访问网络计算机,今天解答win10无法访问局域网电脑的详尽解决举措
  10. 用php计算自由落体,JavaScript模拟自由落体