简体   繁体   English

未能找到可以处理输入的数据适配器:<class 'numpy.ndarray'> , (<class 'list'> 包含类型 {“<class 'int'> ”})</class></class></class>

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

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:我必须将字段转换为 numpy 数组,例如:

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 TensorFlow 中的值错误

https://pythonprogramming.net/convolutional-neural-network-deep-learning-python-tensorflow-keras/ 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所以这发生在较新版本的 tensorflow 我不确定从哪里开始,但我在 2.0.0 版本上,同样的事情发生了

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我假设您只是将 X 数组转换为 numpy 数组而是尝试使用 dtype 作为 np.uint8 将“X”和“y”转换为 numpy 数组

That should resolve the problem那应该可以解决问题

In my case the problem was only in y.就我而言,问题仅出在 y 中。 it was a list.这是一个清单。 in that case i had to change在那种情况下,我不得不改变

y = np.array(y) y = np.array(y)

VIKI already said a good answer. VIKI已经说了一个很好的答案。 I am adding more information.我正在添加更多信息。 It used to crash colab host for me as well, before I added the np.array() wrappers.在我添加 np.array() 包装器之前,它也曾经让我的 colab 主机崩溃。

# 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:由于 memory 问题导致主机崩溃与此有关:

Tensorflow dense gradient explanation? Tensorflow 密集梯度解释?

Mahmud's answer fixes the TensorFlow Tutorial "Basic regression: Predict fuel efficiency" error in section [30]. Mahmud 的回答修复了 [30] 部分中的 TensorFlow 教程“基本回归:预测燃油效率”错误。 These are the 2 lines:这些是 2 行:

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.在将数据放入 model 之前检查类型。 For example, it should be例如,它应该是

print(type(X)) 
# numpy.ndarray

Instead of代替

print(type(X))
# list

Simply transform the X by只需将 X 转换为

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

Just type cast the arrays.只需输入 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 和 y :

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

and for y对于 y

y=np.array(y)

problem with the below line:以下行的问题:

model.fit(X, y, batch_size=32, epochs=3, validation_split=0.3) model.fit(X, y, batch_size=32, epochs=3, validation_split=0.3)

showing error: Failed to find data adapter that can handle input: , ( containing values of types {""})显示错误:未能找到可以处理输入的数据适配器:,(包含类型 {""} 的值)

Please help me how to sort out the issues请帮我解决问题

ValueError:未能找到可以处理输入的数据适配器:<class 'numpy.ndarray'> , <class 'scipy.sparse.csr.csr_matrix'< div><div id="text_translate"><p> 请帮我解决这个问题</p><pre>X_train = np.asarray(X_train) y_train = np.asarray(y_train) X_test = np.asarray(X_test) y_test = np.asarray(y_test) history = model.fit(X_train, y_train, epochs=75, batch_size=batch_size, verbose=2, validation_data=(X_test, y_test), callbacks= [lrate])</pre><p> ValueError:无法找到可以处理输入的数据适配器:&lt;class 'numpy.ndarray'&gt;, &lt;class 'scipy.sparse.csr.csr_matrix' 即使我转换为 numpy 数组,但出现错误。 请帮忙。 谢谢你。</p></div></class></class> - ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'scipy.sparse.csr.csr_matrix'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未能找到可以处理输入的数据适配器:<class 'numpy.ndarray'> , (<class 'list'> 包含类型 {"<class 'float'> "})</class></class></class> - Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'float'>"}) 未能找到可以处理输入的数据适配器:<class 'numpy.ndarray'> , (<class 'list'> c</class></class> - Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> c Tensorflow | ValueError:未能找到可以处理输入的数据适配器:<class 'numpy.ndarray'></class> - Tensorflow | ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'> ValueError:未能找到可以处理输入的数据适配器:<class 'numpy.ndarray'> , <class 'sklearn.preprocessing._encoders.onehotencoder'></class></class> - ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'sklearn.preprocessing._encoders.OneHotEncoder'> ValueError:未能找到可以处理输入的数据适配器:<class 'numpy.ndarray'> , <class 'scipy.sparse.csr.csr_matrix'< div><div id="text_translate"><p> 请帮我解决这个问题</p><pre>X_train = np.asarray(X_train) y_train = np.asarray(y_train) X_test = np.asarray(X_test) y_test = np.asarray(y_test) history = model.fit(X_train, y_train, epochs=75, batch_size=batch_size, verbose=2, validation_data=(X_test, y_test), callbacks= [lrate])</pre><p> ValueError:无法找到可以处理输入的数据适配器:&lt;class 'numpy.ndarray'&gt;, &lt;class 'scipy.sparse.csr.csr_matrix' 即使我转换为 numpy 数组,但出现错误。 请帮忙。 谢谢你。</p></div></class></class> - ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'scipy.sparse.csr.csr_matrix' ValueError:无法找到可以处理输入的数据适配器:<class 'numpy.ndarray'> ,<class 'pandas.core.frame.DataFrame'> - ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'pandas.core.frame.DataFrame'> 兑换 <class 'list'> 到numpy.ndarray - convert <class 'list'> to numpy.ndarray ValueError:未能找到可以处理输入的数据适配器:<class 'nonetype'> ,<class 'nonetype'> 在 keras model.predict</class></class> - ValueError: Failed to find data adapter that can handle input: <class 'NoneType'>, <class 'NoneType'> in keras model.predict 找不到可以处理输入的数据适配器:<class 'nonetype'> ,<class 'nonetype'></class></class> - Failed to find data adapter that can handle input: <class 'NoneType'>, <class 'NoneType'> 断言错误:<class 'numpy.ndarray'> ,同时将数据拆分为测试和训练 - AssertionError: <class 'numpy.ndarray'>, while spiltting the data into test and train
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM