我已经开始学习Tensorflow了。我正在使用Pycharm,我的环境是Ubuntu 16.04。我正在跟踪tutorial。我交叉检查了一下。它是最新的。我不知道这个错误的原因。
from numpy.lib.arraypad import _validate_lengths
ImportError: cannot import name '_validate_lengths'
需要提示来解决此错误。谢谢您。
import tensorflow as tf
from skimage import transform
from skimage import data
import matplotlib.pyplot as plt
import os
import numpy as np
from skimage.color import rgb2gray
import random
#listdir: This method returns a list containing the names of the entries in the directory given by path.
# Return True if path is an existing directory
def load_data(data_dir):
# Get all subdirectories of data_dir. Each represents a label.
directories = [d for d in os.listdir(data_dir)
if os.path.isdir(os.path.join(data_dir, d))]
# Loop through the label directories and collect the data in
# two lists, labels and images.
labels = []
images = []
for d in directories:
label_dir = os.path.join(data_dir, d)
file_names = [os.path.join(label_dir, f)
for f in os.listdir(label_dir)
if f.endswith(".ppm")]
for f in file_names:
images.append(data.imread(f))
labels.append(int(d))
return images, labels
ROOT_PATH = "/home/tahir/PhD Study/Traffic Signs Using Tensorflow/"
train_data_dir = os.path.join(ROOT_PATH, "TrafficSigns/Training")
test_data_dir = os.path.join(ROOT_PATH, "TrafficSigns/Testing")
images, labels = load_data(train_data_dir)
# Print the `images` dimensions
print(images.ndim)
# Print the number of `images`'s elements
print(images.size)
# Print the first instance of `images`
images[0]
scikit图0.14.2适用于numpy 1.16.3。我先安装了numpy,然后安装了scikit映像
pip install scikit-image==0.14.2 && pip install numpy==1.15
参考号:Here
我更新了我的脱脂包。
问题解决了。这是skipage版本的问题,在0.14.2中得到了解决。另外,这个版本相当稳定。
相关问题 更多 >
编程相关推荐