成功解决tensorflow.python.framework.errors_impl.InvalidArgumentError: slice index 1 of dimension 0 out o

简介: 成功解决tensorflow.python.framework.errors_impl.InvalidArgumentError: slice index 1 of dimension 0 out o

解决问题

tensorflow.python.framework.errors_impl.InvalidArgumentError: slice index 1 of dimension 0 out of bounds.


解决思路

tensorflow.python.framework.errors_impl.invalid参数错误:维度0的切片索引1越界。



解决方法

    其实大多是参数问题,比如这个问题我自己看我的代码模型没有毛病,后来发现自己在导入一个模型的时候,忘了修改模型参数与自己train时候用到的参数匹配。

    train时候用的模型有4个输出,原先用于mnist数据集的模型有10个输出,在修改后程序正常运行。 概括地讲,你在restore的时候必须保证当先代码构建的模型与原模型参数匹配,如果不匹配则会报错。当然这个问题尤其在你有多个载入模块的时候,需要仔细校验每一个载入模块的参数类型,数目是否与原来train时候的参数数目匹配。

   唯有如此,才能使自己的模型得到验证工作。


相关文章
|
1月前
|
索引 Python
098-python列表_切片_slice_开始_结束
本文介绍了Python中列表的切片(slice)操作,通过“前闭后开”原则截取列表片段,支持正负索引、省略端点等用法,并结合生活实例(如切面包、直播切片)帮助理解。切片不改变原列表,返回新列表。
213 4
|
3月前
|
数据采集 索引 Python
Python Slice函数使用教程 - 详解与示例 | Python切片操作指南
Python中的`slice()`函数用于创建切片对象,以便对序列(如列表、字符串、元组)进行高效切片操作。它支持指定起始索引、结束索引和步长,提升代码可读性和灵活性。
|
6月前
|
存储 索引 Python
[oeasy]python093_find方法_指数为负数_index_实际效果
本文介绍了Python中`find`方法与索引(index)的使用,包括负数索引的实际效果。回顾了`eval`函数的应用,并强调类名如`str`、`int`、`list`不可用作变量名以避免覆盖。通过示例解析了负数索引在字符串和列表中的作用,以及`index`方法的三个参数(value、start、stop)的用法。同时对比了`index`和`find`方法的区别:`index`找不到子串时抛出`ValueError`,而`find`返回-1。最后总结了正负索引的使用场景及两者的特性,提供了相关学习资源链接。
420 8
|
7月前
|
人工智能 索引 Python
[oeasy]python091_列表_索引_index_中括号_索引函数
本文介绍了Python中列表与字符串的索引及index函数用法。通过range生成列表,使用索引[]访问和修改列表元素,index函数查找元素位置。字符串支持索引访问但不可直接修改。还探讨了16进制数在Python中的表示方法,以及日期、月份等特殊字符的Unicode范围。最后总结了列表与字符串操作的区别,并预告后续内容,提供蓝桥云课、GitHub和Gitee链接供进一步学习。
211 20
|
存储 索引 Python
【Python】已解决:IndexError: list index out of range
【Python】已解决:IndexError: list index out of range
2209 1
|
数据处理 Python
【Python】已解决:SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFram
【Python】已解决:SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFram
2499 1
|
数据挖掘 开发者 索引
【Python】已解决:ValueError: If using all scalar values, you must pass an index
【Python】已解决:ValueError: If using all scalar values, you must pass an index
3543 0
|
开发者 Python
【Python】已解决:TypeError: descriptor ‘index‘ for ‘list‘ objects doesn‘t apply to a ‘str‘ object
【Python】已解决:TypeError: descriptor ‘index‘ for ‘list‘ objects doesn‘t apply to a ‘str‘ object
454 0
Python小姿势 - 5 tips to get the most out of list comprehensions in Python
Python小姿势 - 5 tips to get the most out of list comprehensions in Python
|
索引 Python
Python for循环中使用index索引
Python for循环中使用index索引
1680 0

推荐镜像

更多