[Python] Regression Model Always Predicting Mean Value

Discussão em 'Python' iniciado por Stack, Junho 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on implementing two different models to predicting an optimal tension value to use for cleaving fiber optic cables based off images. I collected the images myself and trained a CNN model to identify good or bad cleaves that I labeled myself. This part seems to be working well. I then am trying to train a regression model to predict a tension value if the image is classified as a bad cleave. However, I the regression model keeps predicting the exact mean value of the tension ranges that I input and I'm not sure why. For reference, the CNN was trained on numerical feature data as well, (e.g. Tension, Angle, Misting, etc.) but I randomly zeroed out these features often to prevent overfitting on the numerical data and not focusing on the image itself. Does anyone have any ideas?

    def _build_pretrained_model(self,
    param_shape: Tuple[int, ...],
    dense1: int,
    dense2: int,
    dense3: int,
    dense_combined: int) -> tf.keras.Model:
    """
    Build MLP model for tension prediction.

    Args:
    param_shape: Dimensions of numerical parameters
    dense1: Dimensionality of first dense layer
    dense2: Dimensionality of second dense layer
    dense3: Dimenionality of third dense layer
    dense_combined: Dimenionaly of combined image and features layer

    Returns:
    tf.keras.Model: Regression model for tension prediction
    """
    self.cnn_model.trainable = False
    x = Dense(dense1, name="first_dense_layer", activation="relu")(self.feature_output)
    x = Dense(dense2, name="second_dense_layer", activation="relu")(x)
    feature_input = Input(shape=param_shape, name="feature_input")
    y = Dense(dense3, name="third_dense_layer", activation="relu")(feature_input)

    combined = Concatenate()([x, y])
    z = Dense(dense_combined, name="dense_combined", activation="relu")(combined)
    output = Dense(1, name="tension_output")(z)
    regression_model = Model(
    inputs=[self.image_input, feature_input], outputs=output
    )
    regression_model.summary()
    return regression_model


    Above is the code I have for the regressor model. I load the pre-trained CNN classifier and then retrain from the feature output layer. I feel like the model isn't associating the tensions values with the images.

    Continue reading...

Compartilhe esta Página