本文整理匯總了Python中tensorflow.python.keras.layers.GlobalAveragePooling2D方法的典型用法代碼示例。如果您正苦於以下問題:Python layers.GlobalAveragePooling2D方法的具體用法?Python layers.GlobalAveragePooling2D怎麽用?Python layers.GlobalAveragePooling2D使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.python.keras.layers
的用法示例。
在下文中一共展示了layers.GlobalAveragePooling2D方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _define_model
# 需要導入模塊: from tensorflow.python.keras import layers [as 別名]
# 或者: from tensorflow.python.keras.layers import GlobalAveragePooling2D [as 別名]
def _define_model(output_layer=-1):
'''Define a pre-trained MobileNet model.
Args:
output_layer: the number of layer that output.
Returns:
Class of keras model with weights.
'''
base_model = MobileNet(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
output = base_model.layers[output_layer].output
output = GlobalAveragePooling2D()(output)
model = Model(inputs=base_model.input, outputs=output)
return model