0

For a pre-trained CNN model in Keras, how to insert a new input layer into hidden layers and remove the layers before the new input layer? For instance, VGG16 is a pre-trained model in Keras and I want to remove the first two layers (input_1 and block1_conv1 layer) and give the rest model a new input layer. The shape is of the input is (None, 224, 224, 64) and original input is (None, 224, 224, 3).

from keras.applications.vgg16 import VGG16
model = VGG16(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000)
...
yann
  • 652
  • 7
  • 14
  • Possible duplicate of [How to split a Keras model, with a non-sequential architecture like ResNet, into sub-models?](https://stackoverflow.com/questions/56147685/how-to-split-a-keras-model-with-a-non-sequential-architecture-like-resnet-into) – today Jun 01 '19 at 06:47
  • The above solution works for both sequential (e.g. VGG16) and non-sequential models (e.g. ResNet). – today Jun 01 '19 at 06:47

0 Answers0