AttributeError: 'list' object has no attribute 'ndim'

简介: AttributeError: 'list' object has no attribute 'ndim'

ERROR:

1. AttributeError                            Traceback (most recent call last)
2. <ipython-input-6-9b77ac20aa23> in <module>()
3.       1 # Print the `images` dimensions
4. ----> 2 print(images.ndim)
5.       3
6.       4 # Print the number of `images`'s elements
7.       5 print(images.size)
8. 
9. AttributeError: 'list' object has no attribute 'ndim'
10.

Solution:

It tried to get shape of input by reading ndim attribute of numpy array and failed.

Just simply transform it using np.array:

1. import numpy as np
2. ...
3. images=np.array(images)
4. labels=np.array(labels)


AIEarth是一个由众多领域内专家博主共同打造的学术平台,旨在建设一个拥抱智慧未来的学术殿堂!【平台地址:https://devpress.csdn.net/aiearth】 很高兴认识你!加入我们共同进步!

目录
相关文章
|
22天前
|
计算机视觉 Python
解决 NoneType‘ object has no attribute ‘astype’ 问题
解决 NoneType‘ object has no attribute ‘astype’ 问题
40 0
|
22天前
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
394 0
|
22天前
|
机器学习/深度学习 监控 数据可视化
【已解决】 ‘Conv2d’ object has no attribute ‘register_full_backward_hook’
【已解决】 ‘Conv2d’ object has no attribute ‘register_full_backward_hook’
|
22天前
|
安全 计算机视觉 Python
【已解决】attributeerror: ‘FreeTypeFont‘ object has no attribute ‘getsize‘
【已解决】attributeerror: ‘FreeTypeFont‘ object has no attribute ‘getsize‘
|
22天前
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
128 0
|
8月前
|
Java
【面试题精讲】Object类的常见方法有哪些?
【面试题精讲】Object类的常见方法有哪些?
|
16天前
|
Java
Java Object 类
5月更文挑战第16天
|
10天前
|
算法 Java 测试技术
简介Object类+接口实例(深浅拷贝、对象数组排序)
简介Object类+接口实例(深浅拷贝、对象数组排序)
|
11天前
|
存储 算法 Java
滚雪球学Java(42):探索对象的奥秘:解析Java中的Object类
【5月更文挑战第17天】🏆本文收录于「滚雪球学Java」专栏,专业攻坚指数级提升,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!
24 2
滚雪球学Java(42):探索对象的奥秘:解析Java中的Object类
|
15天前
|
Java
【JAVA学习之路 | 基础篇】Object类及重写的equals()与toString()
【JAVA学习之路 | 基础篇】Object类及重写的equals()与toString()