python - ValueError:无法将 NumPy 数组转换为张量(不支持的对象类型 numpy.ndarray)。在 jupyternotebook
问题描述
我在 jupyter 中编写代码
print('---------------Data Gathering------------------')
# put The address of test images
directory_location_test = "G:\\ml\\test"
data_test, labels_test = data_extraction(directory_location_test)
testX = np.array(data_test)
#testX = tf.convert_to_tensor(testX)
#testX = testX.astype('int32')
testY = labels_test
但在我的代码显示
<ipython-input-5-9ba842610e7d>:60: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
testX = np.array(data_test)
和错误:请我解决
解决方案
使用加载的数据似乎data_extraction()
不像弃用错误所说的那样具有统一的大小:Creating an ndarray from ragged nested sequences
.
输入数据沿某个轴可能具有不同的长度,例如。data = [[1], [1,2]]
如果没有关于“data_extraction()”是什么的信息,我真的无能为力。
推荐阅读
- javascript - MDC:单击浏览器的后退按钮时,drawer.open 未初始化
- vba - 运行时错误“440”;数组索引超出范围,按索引引用附件时
- memory-management - SQL Server 2014 Express 和实体框架的超时问题
- amazon-ec2 - 主机端口映射不适用于 EC2 上的 docker-compose
- jquery - 无法获取表中“已更改”TD 单元格的“新值”
- r - 如何在R中按组应用多个“if”函数
- java - 如何使用另一个数组列表提供的索引比较数组列表中的元素
- java - 服务器不听请求
- r - 数据框操作:变量操作
- c# - 在公共项目中使用 mimekit nuget 包(通过 paket)从引用公共项目的其他项目中删除现有 System.net.http.dll