I have the following network that will be used for binary classification on medical image data. However, I would like to use only the 80 first layers of this model as I currently don't have a lot of data and my model is overfitting. I would like to delete all layers from block 4 or 5, and only keep blocks 1, 2 and 3. I have tried using layer.pop() but it does not work.
from keras.applications.resnet50 import ResNet50
resnet = ResNet50(include_top=False, weights='imagenet', input_shape=(im_size,im_size,3))
headModel = AveragePooling2D(pool_size=(7, 7))(resnet.output)
headModel = Flatten(name="flatten")(headModel)
headModel = Dense(256, activation="relu")(headModel)
headModel = Dropout(0.5)(headModel)
headModel = Dense(1, activation="sigmoid")(headModel)