ValueError: Layer model_1 expects 1 input(s), but it received 2 input tensors

Viewed 274

I am making face detection system and i am very new to this thing, so apologies in advance if some Information is misseing. Please bear with me:

Below is shown how i created the dataset.

 Preprocess x data
        self.x_train = x_train.astype(np.float32)
        self.x_test = x_test.astype(np.float32)
        self.x_val = x_val.astype(np.float32)
        # Preprocess y data
        self.y_train = to_categorical(y_train, num_classes= self.num_classes)
        self.y_test = to_categorical(y_test, num_classes= self.num_classes)
        self.y_val = to_categorical(y_val, num_classes= self.num_classes)
        
        # Dataset attributes
        self.train_size = self.x_train.shape[0]
        self.test_size = self.x_test.shape[0]
        self.val_size = self.x_val.shape[0]
        self.width = self.x_train.shape[1]
        self.height = self.x_train.shape[2]
        self.depth = self.x_train.shape[3]
        self.img_shape = (self.width, self.height, self.depth)
        
        # tf.data Datasets
        self.train_dataset = tf.data.Dataset.from_tensor_slices((self.x_train, self.y_train))
        self.test_dataset = tf.data.Dataset.from_tensor_slices((self.x_test, self.y_test))
        self.val_dataset = tf.data.Dataset.from_tensor_slices((self.x_val, self.y_val))
        self.train_dataset = self._prepare_dataset(self.train_dataset, shuffle=True, augment=True)
        self.test_dataset = self._prepare_dataset(self.test_dataset)
        self.val_dataset = self._prepare_dataset(self.val_dataset)

    def get_train_set(self) -> tf.data.Dataset:
        return self.x_train, self.y_train

    def get_test_set(self) -> tf.data.Dataset:
        return self.x_test, self.y_test

    def get_val_set(self) -> tf.data.Dataset:
        return self.x_val, self.y_val

    model.fit(
        train_dataset,
        verbose=1,
        batch_size=batch_size,
        epochs=epochs,
        callbacks=[tb_callback],
        validation_data=val_dataset
    )

And after doing this i am recieving an error ValueError: Layer model_1 expects 1 input(s), but it received 2 input tensors I have read the other answers related to this , which mentions giving input as a Tuple (which i tried and it didnt helped). I am doing it on Colab with tensorflow version = 2.4.1. I would appreciate if anyone can help me with this error. Thanks in advance. Stay healthy.

0 Answers
Related