AssertionError: Could not compute output Tensor(“dense_8/truediv:0”, shape=(None, 8, 7), dtype=float32)

Im trying to create a 2 branch CNN for image classification.my images are stored in test validation training sets as numpy arrays and this is my co

def getBranch(input_layer, n_filters, dropOut, suffix):
    n_feature_maps = 128
    dropOut = 0.2
    
    conv_x = tfk.layers.Conv1D(filters=n_feature_maps, kernel_size=5, padding='same', name="conv1_"+suffix, activation="relu")(input_layer)
    conv_x = tfk.layers.BatchNormalization(name="bn1_"+suffix)(conv_x)
    conv_x = tfk.layers.Dropout(dropOut, name="dropOut1_"+suffix)(conv_x)

    conv_x = tfk.layers.Conv1D(filters=n_feature_maps, kernel_size=3, padding='same', name="conv2_"+suffix, activation="relu")(conv_x)
    conv_x = tfk.layers.BatchNormalization(name="bn2_"+suffix)(conv_x)
    conv_x = tfk.layers.Dropout(dropOut, name="dropOut2_"+suffix)(conv_x)

    conv_x = tfk.layers.Conv1D(filters=n_feature_maps*2, kernel_size=3, padding='same', name="conv3_"+suffix, activation="relu")(conv_x)
    conv_x = tfk.layers.BatchNormalization(name="bn3_"+suffix)(conv_x)
    conv_x = tfk.layers.Dropout(dropOut,name="dropOut3_"+suffix)(conv_x)

    conv_x = tfk.layers.Conv1D(filters=n_feature_maps*2, kernel_size=1, padding='same', name="conv4_"+suffix, activation="relu")(conv_x)
    conv_x = tfk.layers.BatchNormalization(name="bn4_"+suffix)(conv_x)
    conv_x = tfk.layers.Dropout(dropOut,name="dropOut4_"+suffix)(conv_x)

    return conv_x


def build_model(input_shape1, input_shape2, nb_classes):
    n_feature_maps = 128
    dropOut = 0.2

    input_layer1 = tfk.layers.Input(name="input1", shape=(input_shape1))
    input_layer2 = tfk.layers.Input(name="input2", shape=(input_shape1))

    features1 = getBranch(input_layer1, n_feature_maps, dropOut, "input1")
    features2 = getBranch(input_layer2, n_feature_maps, dropOut, "input2")

    
    features = tfk.layers.Concatenate(name="concat_layer")([features1, features2])
    dense_layer = tfk.layers.Dense(512, activation='sigmoid')(features)
    dense_layer = tfk.layers.Dense(512, activation='sigmoid')(dense_layer)
    output_layer = tfk.layers.Dense(nb_classes, activation='softmax')(dense_layer)

    model = tfk.models.Model(inputs=[input_layer1, input_layer2], outputs=output_layer)
    #the model compile can be done outside this method or inside, as you prefer
    model.compile(loss='sparse_categorical_crossentropy', optimizer=tfk.optimizers.Adam(), metrics=['accuracy'])

    return model

if __name__=="__main__":
    model= build_model((8, 4), (8, 4), 7)

The output of the summury is

concat_layer (Concatenate)      (None, 8, 512)       0           dropOut4_input1[0][0]            
                                                                 dropOut4_input2[0][0]            
__________________________________________________________________________________________________
dense_15 (Dense)                (None, 8, 512)       262656      concat_layer[0][0]               
__________________________________________________________________________________________________
dense_16 (Dense)                (None, 8, 512)       262656      dense_15[0][0]                   
__________________________________________________________________________________________________
dense_17 (Dense)                (None, 8, 7)         3591        dense_16[0][0] 

when fiting the model with that…it crashes in the second iteration

y_train1 = to_categorical(y_train,8)
y_test1 = to_categorical(y_test, 8)
y_valid1 = to_categorical(y_valid, 8)

x_train.shape,y_train1.shape,x_test.shape,y_test1.shape,x_valid.shape,y_valid1.shape,

((356722, 8, 4),
 (356722, 8),
 (290726, 8, 4),
 (290726, 8),
 (167419, 8, 4),
 (167419, 8))

this error appears

Epoch 1/50 5574/5574 [==============================] - ETA: 0s - loss: 0.1205 - accuracy: 0.9533
AssertionError AssertionError: Could not compute output Tensor(“dense_8/truediv:0”, shape=(None, 8, 7),dtype=float32)

Hi, this seems to be a question related to Keras. You are in pytorch forum.
You sure this is the correct forum to ask this question?