【发布时间】:2017-05-06 17:58:51
【问题描述】:
我正在尝试编辑一些示例张量代码流,以使用一些数据训练和测试卷积神经网络。我目前有以下代码设置张量流并从文件中获取我的图像数据:
mnist_classifier = learn.Estimator(
model_fn=cnn_model_fn, model_dir="/tmp/mnist_convnet_model")
tensors_to_log = {"probabilities": "softmax_tensor"}
logging_hook = tf.train.LoggingTensorHook(
tensors=tensors_to_log, every_n_iter=50)
testImages = []
testLabels = []
for filename in os.listdir('images'):
im = cv2.imread('images/' + filename)
testImages.append(im)
testLabels.append(np.int32(1.0))
for filename in os.listdir('badImages'):
im = cv2.imread('badImages/' + filename)
testImages.append(im)
testLabels.append(np.int32(0.0))
然后我尝试使用以下行拟合模型:
mnist_classifier.fit(
x=testImages,
y=testLabels,
batch_size=10,
steps=20000,
monitors=[logging_hook])
但这会在运行时崩溃并出现以下错误:
if x_is_dict else check_array(x, x.dtype)
AttributeError: 'list' object has no attribute 'dtype'
似乎是说我的 testImages var 的结构/格式存在一些问题,但我已经确认它是正确的类型 - numpy.ndarray 的 numpy.ndarrays。有什么想法吗?
【问题讨论】:
标签: python numpy machine-learning tensorflow