简体   繁体   English

如何将一个功能性 Resnet50 model 分解为多层

[英]How to break one Functional Resnet50 model into multiple layer

I created Resnet50 using:我使用以下方法创建了 Resnet50:

     base_model = tf.keras.applications.ResNet50(include_top=False, weights=None, input_shape=(224, 224, 3))
    base_model.trainable = True
    
    inputs = Input((224, 224, 3))
    h = base_model(inputs, training=True)
    model = Model(inputs, projection_3)

model summary: model总结:

Layer (type)                Output Shape              Param #   
=================================================================
 input_image (InputLayer)    [(None, 256, 256, 3)]     0         
                                                                 
 resnet50 (Functional)       (None, 8, 8, 2048)        23587712  
                                                                 
=================================================================

Later, I realized I need to access some layer like this:后来,我意识到我需要像这样访问一些层:

Resmodel.layers[4].output

However, I got:但是,我得到了:

IndexError: list index out of range

Is there away to break the Resnet50 funcational model into mutpile layer OR there away to access a certain layer of the model .是否可以将 Resnet50 功能性 model 分解为多重层或访问 model 的某个层

try this尝试这个

model.layers[1].layers[4] model.layers[1].layers[4]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM