If I want to split Resnet50 at what point is that feasible. The last layer being dense 1000 has to change for dogscats to dense 2. I am not sure where and how to cut it.
In Resnet50 we have 3 layers at the bottom AveragePooling2D -> Flatten -> Dense the final layer.
In previous splits with vgg16 we cut on the Flatten layer and then add BatchNormalization etc
Or simply just remove the last dense layer and replace with Dense(2,activation='softmax')
When I do this I get an error when I want to see if the layer is there using model.summary() :: tried to call xxxx but layer isn't built.
Not sure what that means with Resnet50 model
Ok I guess I just bumped up against the Functional API
def finetune(self, batches):
model = self.model
for layer in model.layers: layer.trainable=False
m = Dense(batches.nb_class, activation='softmax')(model.layers[-1].output)
self.model = Model(model.input, m)
self.model.compile(optimizer=RMSprop(lr=0.1), loss='categorical_crossentropy', metrics=['accuracy'])
I finally have a model compiled using the lines from this function and modifying them for application directly against the model defined in my notebook. I could not call this function from the model Resnet50 I imported. Perhaps because I only imported that by name.
I can now see in my model summary that the output is a 2way softmax called output.