Ошибка в Обучении нейронной сети тапа данных
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 'str'>"}) Датасет одной картинки
Полный код
import tensorflow as tf
from google.colab import drive
drive.mount('/content/drive')
import numpy as np
from PIL import Image
im = []
labels = ["raspberry","someduino"]
lab = []
for typ in range(2):
for train in range(1,128):
img = Image.open(labels[typ] + "/" + str(train) + '.jpg')
im.append(np.array(img))
lab.append(labels[typ])
print("progress ", str(typ) + "." + str(train))
print(im)
train_images = im
train_labels = lab
print(train_images)
print(train_images)
import matplotlib.pyplot as plt
plt.figure(figsize=(10,12))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i+150], cmap=plt.cm.binary)
plt.xlabel(train_labels[i+150])
plt.show()
model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(1, activation='relu'),
tf.keras.layers.Dropout(0,999),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(train_images, train_labels, epochs=1)
ERROR: ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-28-e126e5caf70f> in <cell line: 1>()
----> 1 model.fit(train_images, train_labels, epochs=1)
1 frames
/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py in error_handler(*args, **kwargs)
68 # To get the full stack trace, call:
69 # `tf.debugging.disable_traceback_filtering()`
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
/usr/local/lib/python3.10/dist-packages/keras/src/engine/data_adapter.py in select_data_adapter(x, y)
1103 if not adapter_cls:
1104 # TODO(scottzhu): This should be a less implementation-specific error.
-> 1105 raise ValueError(
1106 "Failed to find data adapter that can handle input: {}, {}".format(
1107 _type_name(x), _type_name(y)
ValueError: Failed to find data adapter that can handle input: (<class 'list'> containing values of types {"<class 'numpy.ndarray'>"}), (<class 'list'> co
ntaining values of types {"<class 'str'>"})