当前位置:   article > 正文

cannot import name ‘_validate_lengths‘ from ‘numpy.lib.arraypad‘

cannot import name ‘_validate_lengths‘ from ‘numpy.lib.arraypad‘

Ask Question

Asked 1 year, 6 months ago

Active 3 months ago

Viewed 38k times

68

I have started learning Tensorflow. I am using Pycharm and my environment is Ubuntu 16.04. I am following the tutorial. I cross check the nump. It is up-to-date. I don't know the reason of this error.

from numpy.lib.arraypad import _validate_lengths

ImportError: cannot import name '_validate_lengths'

Need hint to resolve this error. Thank you.

  1. import tensorflow as tf
  2. from skimage import transform
  3. from skimage import data
  4. import matplotlib.pyplot as plt
  5. import os
  6. import numpy as np
  7. from skimage.color import rgb2gray
  8. import random
  9. #listdir: This method returns a list containing the names of the entries in the directory given by path.
  10. # Return True if path is an existing directory
  11. def load_data(data_dir):
  12. # Get all subdirectories of data_dir. Each represents a label.
  13. directories = [d for d in os.listdir(data_dir)
  14. if os.path.isdir(os.path.join(data_dir, d))]
  15. # Loop through the label directories and collect the data in
  16. # two lists, labels and images.
  17. labels = []
  18. images = []
  19. for d in directories:
  20. label_dir = os.path.join(data_dir, d)
  21. file_names = [os.path.join(label_dir, f)
  22. for f in os.listdir(label_dir)
  23. if f.endswith(".ppm")]
  24. for f in file_names:
  25. images.append(data.imread(f))
  26. labels.append(int(d))
  27. return images, labels
  28. ROOT_PATH = "/home/tahir/PhD Study/Traffic Signs Using Tensorflow/"
  29. train_data_dir = os.path.join(ROOT_PATH, "TrafficSigns/Training
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/657830
推荐阅读
相关标签
  

闽ICP备14008679号