无法使用tflearn将图像数据集加载到python中

时间:2017-04-05 00:36:34

标签: python machine-learning tensorflow tflearn

我无法使用tflearn将图像数据集加载到python中     它给我一个错误......

TypeError: image_preloader() got an unexpected keyword argument 'categorical_lables'

以下是代码..

from __future__ import division, print_function, absolute_import

import tflearn
import tensorflow as tf
from tflearn.data_utils import shuffle
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.estimator import regression
from tflearn.data_preprocessing import ImagePreprocessing
from tflearn.data_augmentation import ImageAugmentation
import pickle

dataset_file = 'data.txt'
from tflearn.data_utils import image_preloader
X,Y=image_preloader(dataset_file, image_shape=(100,100),mode=file,categorical_lables=True,normalize=True)
img_prep = ImagePreprocessing()
img_prep.add_featurewise_zero_center()
img_prep.add_featurewise_stdnorm()
network = input_data(shape=[None, 32, 32, 3],
                     data_preprocessing=img_prep,
                 data_augmentation=img_aug)
network = conv_2d(network, 32, 3, activation='relu')
network = max_pool_2d(network, 2)
network = conv_2d(network, 64, 3, activation='relu')
network = conv_2d(network, 64, 3, activation='relu')
network = max_pool_2d(network, 2)
network = fully_connected(network, 512, activation='relu')
network = dropout(network, 0.5)
network = fully_connected(network, 2, activation='softmax')
network = regression(network, optimizer='adam',
                 loss='categorical_crossentropy',
                 learning_rate=0.001)
model = tflearn.DNN(network, tensorboard_verbose=0, checkpoint_path='bird-classifier.tfl.ckpt')
model.fit(X, Y, n_epoch=100, shuffle=True, validation_set=(X_test, Y_test),
      show_metric=True, batch_size=96,
      snapshot_epoch=True,
      run_id='bird-classifier')

和data.txt文件constains / path / to / image class

示例 img1.jpeg 0 img2.jpeg 1 。 。 。 。 。 。

1 个答案:

答案 0 :(得分:2)

也许检查categorical_labels上的拼写。