import tensorflow as tf
from tensorflow import keras
resnet = keras.applications.ResNet50(weights="imagenet",include_top=False)
Downloading data from https://github.com/keras-team/keras-applications/releases/download/resnet/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5
resnet.summary()
x = tf.random.normal([4,224,224,3])
out = resnet(x)
########全局池化层降维
global_average_layer = keras.layers.GlobalAveragePooling2D()
x = tf.random.normal([4,7,7,2048])
out = global_average_layer(x) #####输出(4,2048)
fc = keras.layers.Dense(100)
myNet = keras.Sequential([resnet,global_average_layer,fc])
mynet.summary()