tensorflow获取所有层以及每一层的名字

代码示例

# 以resnet101为例
resnet101_model = tf.keras.applications.ResNet101(include_top = False, weights=None, input_shape=(224, 224, 1))
resnet101_model.summary()
# 获取所有层,返回层对象列表
layers = resnet101_model.layers
# 获取每一层名字
for layer in layers:
    print(layer.name)

你可能感兴趣的:(tensorflow,python,tensorflow)