Нашел ответ здесь .
import tensorflow as tf
input_shape = (224, 224, 3)
base_model = tf.keras.applications.ResNet50(input_shape=input_shape, include_top=False, weights='imagenet')
# Get the output of conv4
conv4_block6_out = base_model.get_layer('conv4_block6_out').output
x = tf.keras.layers.Softmax()(conv4_block6_out)
model = tf.keras.Model(base_model.input, x)
model.summary()
Результаты:
Model: "model_3"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_2 (InputLayer) [(None, 224, 224, 3) 0
__________________________________________________________________________________________________
conv1_pad (ZeroPadding2D) (None, 230, 230, 3) 0 input_2[0][0]
__________________________________________________________________________________________________
conv1_conv (Conv2D) (None, 112, 112, 64) 9472 conv1_pad[0][0]
__________________________________________________________________________________________________
conv1_bn (BatchNormalization) (None, 112, 112, 64) 256 conv1_conv[0][0]
__________________________________________________________________________________________________
conv1_relu (Activation) (None, 112, 112, 64) 0 conv1_bn[0][0]
...
__________________________________________________________________________________________________
conv4_block6_out (Activation) (None, 14, 14, 1024) 0 conv4_block6_add[0][0]
__________________________________________________________________________________________________
softmax_4 (Softmax) (None, 14, 14, 1024) 0 conv4_block6_out[0][0]
==================================================================================================
Total params: 8,589,184
Trainable params: 8,558,592
Non-trainable params: 30,592