4

I have a list X in python which contains 20000 images of dimension (100,100,3) each. Each of the images is of type numpy.ndarray. I wish to input this list of images as the training vector for a CNN model using model.fit(X) in Tensorflow. However doing so gives me the following error:

ValueError: Failed to find data adapter that can handle input: (<class 'list'> containing values of types {"<class 'numpy.ndarray'>"}), (<class 'list'> containing values of types {"<class 'numpy.int64'>"})

Would converting list X into a numpy.ndarray of dimensions (20000,100,100,3) help?

If yes, how can I do that?

If not, could you please suggest what can be done?

1
  • What does np.array(X) produce? Especially what's the shape and dtype? Beware of 1d array with object dtype - the means the list contains arrays that differ in shape. Commented Oct 1, 2020 at 22:33

1 Answer 1

1

When you give a list of np.array as input to fit() method, is considered as your model has multiple inputs.Yes, you have to create a np.array or tf.tensor from the listX. It is a good thing to convert your data to tf.data.dataset :

data_set = tf.data.Dataset.from_tensor_slices(  (your_converted_listX ,your_converted_listY) )
model.fit(data_set)

if the data is too large ,consider using tf.data.Dataset.from_generator instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.