keras:一层作为模型的提取器
对于在keras模型中获得中间层的输出,有几个很好的答案。但是我想在keras模型中提取一个层,并使用层的输入作为新模型的输入,输出作为新模型的输出。我试过:keras:一层作为模型的提取器,keras,Keras,对于在keras模型中获得中间层的输出,有几个很好的答案。但是我想在keras模型中提取一个层,并使用层的输入作为新模型的输入,输出作为新模型的输出。我试过: extractor = Model(model.get_layer('dw_conv5').input, model.get_layer('dw_conv5').output) 但有一个错误: 模型的输入层必须是InputLayer对象。接收到的输入:张量(“漏吕4/LeakyRelu/Maximum:0”,shape=(?,3,3,2
extractor = Model(model.get_layer('dw_conv5').input, model.get_layer('dw_conv5').output)
但有一个错误:
模型的输入层必须是InputLayer
对象。接收到的输入:张量(“漏吕4/LeakyRelu/Maximum:0”,shape=(?,3,3,256),dtype=float32)。输入0(基于0)源于图层类型LeakyReLU
TypeError:a模型的输入层必须是InputLayer
对象
inputs = Input(a_compatible_shape)
outputs = model.get_layer('dw_conv5')(inputs)
model = Model(inputs,outputs)