当前位置:   article > 正文

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

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. AttributeError: 'list' object has no attribute 'ndim'

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)
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/782830
推荐阅读
相关标签
  

闽ICP备14008679号