简体   繁体   中英

How to break one Functional Resnet50 model into multiple layer

I created Resnet50 using:

     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:

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 .

try this

model.layers[1].layers[4]

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.

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