Suppose we have a model already trained for some task can we use that models prediction as a lambda layer inside another model? I am thinking something in the following format:
pretrained_model=get_Model() #Loaded from a different file
pretrained_model.load_weights('pretrained_model_weights.h5')
base_model = VGG16(weights = 'imagenet',include_top=False,input_shape (240,320,3))
for layer in base_model.layers:
layer.trainable = True
img_input=base_model.input
encoded=base_model.output
pretrained_model_output=Lambda(lambda x: pretrained_model.predict(img_input))
#Then run pretrained_model_output through an architecture that gives same output size as base_model.output and then
concat = Concatenate([img_input,Output_Convolutions_pretrained_model_output],axis=-1)
#then feed this through another block in the model
Is something like this viable in Keras?
这比您想象的要容易得多,您只需要执行以下操作:
pretrained_model_output= pretrained_model(img_input)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.