I'm using Keras to do the modelling works and I wonder is it possible to remove certain layers by index or name? Currently I only know the model.pop()
could do this work but it just removes the most recently added layers. In addition, layers
is the type of tensorvariable
and I have no idea how to remove certain element which can be done in numpy array
or list
. BTW I'm using Theano backend.
Keras remove layers after model.fit()
Asked Answered
It is correct that model.pop() just removes the last added layer and there is no other documented way to delete intermediate layers.
You can always get the output of any intermediate layer like so:
base_model = VGG19(weights='imagenet')
model = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_pool').output)
Example taken from here: https://keras.io/applications/
Than add your new layers on top of that.
© 2022 - 2024 — McMap. All rights reserved.
layers
andtensorvariable
? Thanks in advance. – Anticholinergic