Reputation: 67
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?
Upvotes: 4
Views: 4950
Reputation: 1194
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.
Upvotes: 1