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

46,799

Solution 1

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!

Solution 2

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)

Solution 3

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

Solution 4

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

y = np.array(y)

Solution 5

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?

Share:
46,799
Admin
Author by

Admin

Updated on June 16, 2021

Comments

  • Admin
    Admin about 3 years
    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'>"})