mrdbourke / tensorflow-deep-learning

All course materials for the Zero to Mastery Deep Learning with TensorFlow course.
https://dbourke.link/ZTMTFcourse
MIT License
5.14k stars 2.53k forks source link

Failed to find data adapter that can handle input: <class 'int'>, <class 'numpy.ndarray'> #382

Closed kelixirr closed 2 years ago

kelixirr commented 2 years ago

Facing this issue with the latest version of Tensorflow. Classification Problem: Video: 96


model_10 = Sequential([
 Conv2D(10, 3, input_shape=(224, 224, 3)),
 Activation(activation='relu'),
 Conv2D(10, 3, activation='relu'),
 MaxPool2D(),
 Conv2D(10, 3, activation='relu'),
 Conv2D(10, 3, activation='relu'),
 MaxPool2D(),
 Flatten(),
 Dense(10, activation="softmax")                     
])

model_10.compile(loss='categorical_crossentropy',
                 optimizer=tf.keras.optimizers.Adam(),
                 metrics=['accuracy'])

history_10 = model_10.fit(train_data_augmented, 
                          epochs=5, 
                          steps_per_epoch=len(train_data_augmented),
                          validation_data=test_data,
                          validation_steps=len(test_data))

Error

Epoch 1/10
1857/1875 [============================>.] - ETA: 0s - loss: 1.0380 - accuracy: 0.6465
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-17-652a679a1f23>](https://localhost:8080/#) in <module>()
     13 
     14 norm_history = model_13.fit(tf.expand_dims(train_data_norm, axis=-1), train_labels, epochs=10,
---> 15                             validation_data=(test_data_norm, test_labels))

1 frames
[/usr/local/lib/python3.7/dist-packages/keras/engine/data_adapter.py](https://localhost:8080/#) in select_data_adapter(x, y)
    985         "Failed to find data adapter that can handle "
    986         "input: {}, {}".format(
--> 987             _type_name(x), _type_name(y)))
    988   elif len(adapter_cls) > 1:
    989     raise RuntimeError(

**ValueError:** **_Failed to find data adapter that can handle input: <class 'int'>, <class 'numpy.ndarray'>_**
mrdbourke commented 2 years ago

Closing this to continue here: #377