cou*_*uch 2 machine-learning deep-learning keras tensorflow valueerror
所以我在运行这行代码时遇到了 TensorFlow 的一些问题:
history = model.fit(X, y, batch_size=32, epochs=40, validation_split=0.1)
Run Code Online (Sandbox Code Playgroud)
回溯如下:
Traceback (most recent call last):
File "cnnmodel.py", line 71, in <module>
history = model.fit(X, y, batch_size=32, epochs=40, validation_split=0.1)
File "C:\Users\couch\PyMOL\envs\test\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 728, in fit
use_multiprocessing=use_multiprocessing)
File "C:\Users\couch\PyMOL\envs\test\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 224, in fit
distribution_strategy=strategy)
File "C:\Uslow_core\python\keras\engine\training_v2.py", line 497, in _process_training_inputs
adapter_cls = data_adapter.select_data_adapter(x, y)
File "C:\Users\couch\PyMOL\envs\test\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py", line 653, in select_data_adapter
_type_name(x), _type_name(y)))
ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'int'>"})
Run Code Online (Sandbox Code Playgroud)
X 数据是像素值的 numpy 数组,Y 数据是标签列表。
X 和 Y 数据使用pickle 和...重新格式化。
import pickle
import numpy
X = pickle.load(open("X.pickle", "rb"))
y = pickle.load(open("y.pickle", "rb"))
print(X[0][0:64])
print(y[0:10])
Run Code Online (Sandbox Code Playgroud)
产量:
[[[2]
[2]
[2]
...
[1]
[1]
[1]]
[[2]
[2]
[2]
...
[1]
[1]
[1]]
[[2]
[2]
[2]
...
[1]
[1]
[1]]
...
[[0]
[0]
[0]
...
[0]
[0]
[0]]
[[0]
[0]
[0]
...
[0]
[0]
[0]]
[[0]
[0]
[0]
...
[0]
[0]
[0]]]
[3, 3, 0, 0, 3, 4, 3, 1, 4, 4]
Run Code Online (Sandbox Code Playgroud)
关于如何解决问题的任何想法?
| 归档时间: |
|
| 查看次数: |
1990 次 |
| 最近记录: |