在keras模型中获得中间层的输出有几个很好的答案 . 但是我想在keras模型中提取一个层,并使用图层的输入作为新模型的输入,输出作为新模型的输出 . 我试过了:
extractor = Model(model.get_layer('dw_conv5').input, model.get_layer('dw_conv5').output)
但是有一个错误:
模型的输入图层必须是InputLayer对象 . 收到的输入:Tensor(“leaky_re_lu_4 / LeakyRelu / Maximum:0”,shape =(?,3,3,256),dtype = float32) . 输入0(从0开始)源自层类型LeakyReLU .
1 回答