I am not sure how to get output of an intermediate layer in Keras. I have read the other questions on stackoverflow but they seem to be functions with a single sample as input. I want to get output features(at intermediate layer) in batches as well. Here is my model:
model = Sequential()
model.add(ResNet50(include_top = False, pooling = RESNET50_POOLING_AVERAGE, weights = resnet_weights_path)) #None
model.add(Dense(784, activation = 'relu'))
model.add(Dense(NUM_CLASSES, activation = DENSE_LAYER_ACTIVATION))
model.layers[0].trainable = True
After training the model, in my code I want to get the output after the first dense layer (784 dimensional). Is this the right way to do it?
pred = model.layers[1].predict_generator(data_generator, steps = len(data_generator), verbose = 1)
I am new to Keras so I am a little unsure. Do I need to compile the model again after training?