I am working on a AI based project wherein I have trained a CNN model and its name is cifar10.h5. I want to pass certain images from this per-trained model and extract feature vectors of these images from its penultimate layer.
My code snippet is as under :-
original_model = load_model(‘/kaggle/input/models/cifar10.h5’)
layer_before_softmax_output = original_model.layers[-2].output
layer_before_softmax_model = keras.models.Model(inputs = original_model.input, outputs=layer_before_softmax_output)
I was expecting that layer_before_softmax_model will be my new model with output layer as penultimate layer of original model. But I am getting the following error:-
ValueError: The layer sequential_1 has never been called and thus has no defined input.