Reputation: 357
I'm using the tutorial about convolutional neural networks. In this function, I use:
# Train the model
train_input_fn = tf.estimator.inputs.numpy_input_fn(
x={"x": X_train},
y=y_train,
batch_size=100,
num_epochs=None,
shuffle=True)
mnist_classifier.train(
input_fn=train_input_fn,
steps=20000,
hooks=[logging_hook])
where
type(X_train)
list
type(y_train)
list
y_train[0]
'0'
X_train[0].shape
(30, 29, 3)
type(X_train[0])
numpy.ndarray
len(X_train)
39209
len(y_train)
39209
I get the following error: AttributeError: 'list' object has no attribute 'shape'
Upvotes: 1
Views: 2419
Reputation: 7700
X_train
looks like a list of numpy arrays and tensorflow expects a numpy array, you can simply convert it to a numpy array by:
X_train = np.array(X_train)
or using numpy.asarray function, which does the exact same thing as above:
X_train = np.asarray(X_train)
Bear in mind, all your images should have the same dimensions for conversion to work.
Upvotes: 1