Вы можете разделить вашу модель на две модели:
Предыдущая модель:
input = Input(...)
# Your Layers
output = Dense(1)
old_model = Model(inputs=[input], output)
Новая модель:
input = Input(...)
#Add the first layers and the CNN here
cnn_layer = Conv2D(...)
feature_extraction_model = Model(inputs=[input], outputs=cnn_layer)
input_cnn = Input(...) # The shape of your CNN output
# Add the classification layer here
output = Dense(1)
classifier_model = Model(inputs=[input_cnn], outputs=output)
Теперь вы определяете новую модель каккомбинация: feature_extraction_model и classifier_model
new_model = Model(inputs=[input], outputs=classifier_model(input_cnn))
# Train the model
new_model.fit(x, y)
Теперь вы можете получить доступ к обучению после CNNlayer:
cnn_output = feature_extraction_model.predict(x)