history = model.fit(X, y, batch_size=32, epochs=40, validation_split=0.1)

the line problem was this

Showing error:

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

I was facing the same issue. Turns out it was a in the form of a list. I had to convert the fields into a numpy array like:

training_padded = np.array(training_padded)
training_labels = np.array(training_labels)
testing_padded = np.array(testing_padded)
testing_labels = np.array(testing_labels)

thats it!

ValueError in TensorFlow

https://pythonprogramming.net/convolutional-neural-network-deep-learning-python-tensorflow-keras/

I tried following code and worked for me:

IMG_SIZE = 50

X = np.array(X).reshape(-1, IMG_SIZE, IMG_SIZE, 1)

y = np.array(y)

history = model.fit(X, y, batch_size=32, epochs=40, validation_split=0.1)

So this is happening the the newer version of tensorflow I’m not sure from where but I was on version 2.0.0 and this same thing happened

I’m assuming that you are only converting the X array into a numpy array
But rather try converting ‘X’ as well as ‘y’ to numpy array using the dtype as np.uint8

That should resolve the problem

In my case the problem was only in y. it was a list. in that case i had to change

y = np.array(y)

VIKI already said a good answer. I am adding more information. It used to crash colab host for me as well, before I added the np.array() wrappers.

# Need to call np.array() around pandas dataframes.
# This crashes the colab host from TF attempting a 32GB memory alloc when np.array() wrappers are not used around pandas dataframes.
# Wrapping also cures warning about "Failed to find data adapter that can handle input"
history = model.fit(x=np.array(tr_X), y=np.array(tr_Y), epochs=3, validation_data=(np.array(va_X), np.array(va_Y)), batch_size=batch_size, steps_per_epoch=spe, validation_freq=5)

Crashing host due to out of memory problem has something to do with this:

Tensorflow dense gradient explanation?

Mahmud’s answer fixes the TensorFlow Tutorial “Basic regression: Predict fuel efficiency” error in section [30]. These are the 2 lines:

Change this:

example_batch = normed_train_data[:10]
example_result = model.predict(example_batch)

To this:

example_batch = np.array(normed_train_data[0:10]) 
example_result = model.predict(example_batch)

Thanks Mahmud

For those who encounter this issue:

Check the type before you throw your data into the model.
For example, it should be

print(type(X)) 
# numpy.ndarray

Instead of

print(type(X))
# list

Simply transform the X by

import numpy as np
X = np.array(X)

Just type cast the arrays.

for example:

import numpy as np
features = np.array(features,dtype="float64")
labels = np.array(labels, dtype="float64")

you need to convert X and y like this:

X = np.array(X).reshape(-1, 50, 50, 1)

and for y

y=np.array(y)