I am having an issue of where I am obtaining an error to do with the input shapes for the CNN model.
The code for the model
text_input = Input(shape = (max_len,), name = 'text_input')
numerical_input = Input(shape = (train_num_scaled.shape[1],), name = 'numerical_input')
embedding = Embedding(input_dim = vocab_size, input_length = max_len, output_dim = 100,
input_shape = (40,), weights = [glove_embedding_matrix],
trainable = False)(text_input)
con = Conv1D(filters = 128, kernel_size = 3, activation = 'relu')(embedding)
text_feature = GlobalMaxPooling1D()(con)
numerical_features = Dense(units = 64, activation = 'relu')(numerical_input)
concat = Concatenate()([text_feature, numerical_features])
fully_con = Dense(units = 64, activation = 'relu')(concat)
output = Dense(units = 1, activation = 'sigmoid')(fully_con)
cnn_model = Model(inputs = [text_input, numerical_input], outputs = output)
cnn_model.summary()
cnn_model.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics =
['accuracy'])
The output for the model indicates some sort of issue with the shape of the inputs - suggesting that I am using a Sequential model which isn't the case. The user warning is:
C:\Users---\Python\Lib\site-packages\keras\src\layers\core\embedding.py:90: UserWarning: Argument input_length is deprecated. Just remove it.
warnings.warn(
C:\Users---\Python\Lib\site-packages\keras\src\layers\core\embedding.py:93: UserWarning: Do not pass an input_shape/input_dim argument to a layer. When using Sequential models, prefer using an Input(shape) object as the first layer in the model instead.
super().init(**kwargs)
I then fit the model where again a user error comes up also suggesting an issue with the structure/shape of the inputs but it still runs all the epochs.
The code:
history = cnn_model.fit( x = [train_pad_tweets, train_num_scaled],
y = train_target,
validation_data = ([val_pad_tweets, val_num_scaled],
val_target),
epochs = 10, batch_size = 32)
#while this works technically - seems to be a warning about the expected and recieved
structure
The error:
C:\Users----\Python\Lib\site-packages\keras\src\models\functional.py:225: UserWarning: The structure of inputs doesn't match the expected structure: ['text_input', 'numerical_input']. Received: the structure of inputs=('', '')
warnings.warn(
I cannot figure out why there is a potential issue with the shapes of inputs or is this is causing an actual potential issue.
I have attempted putting the history fit in a dictory style format however that is leading to more error again around the shape of the data