本文整理匯總了Python中tensorflow.python.keras.layers.MaxPooling2D方法的典型用法代碼示例。如果您正苦於以下問題:Python layers.MaxPooling2D方法的具體用法?Python layers.MaxPooling2D怎麽用?Python layers.MaxPooling2D使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.python.keras.layers
的用法示例。
在下文中一共展示了layers.MaxPooling2D方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: architecture
# 需要導入模塊: from tensorflow.python.keras import layers [as 別名]
# 或者: from tensorflow.python.keras.layers import MaxPooling2D [as 別名]
def architecture(inputs):
""" Architecture of model """
conv1 = Conv2D(32, kernel_size=(3, 3),
activation='relu')(inputs)
max1 = MaxPooling2D(pool_size=(2, 2))(conv1)
conv2 = Conv2D(32, (3, 3), activation='relu')(max1)
max2 = MaxPooling2D(pool_size=(2, 2))(conv2)
conv3 = Conv2D(64, (3, 3), activation='relu')(max2)
max3 = MaxPooling2D(pool_size=(2, 2))(conv3)
flat1 = Flatten()(max3)
dense1 = Dense(64, activation='relu')(flat1)
drop1 = Dropout(0.5)(dense1)
return drop1
示例2: _build_model
# 需要導入模塊: from tensorflow.python.keras import layers [as 別名]
# 或者: from tensorflow.python.keras.layers import MaxPooling2D [as 別名]
def _build_model(self, input_shape):
x = Input(shape=(32, 32, 3))
y = x
y = Convolution2D(
filters=64,
kernel_size=3,
strides=1,
padding="same",
activation="relu",
kernel_initializer="he_normal")(y)
y = Convolution2D(
filters=64,
kernel_size=3,
strides=1,
padding="same",
activation="relu",
kernel_initializer="he_normal")(y)
y = MaxPooling2D(pool_size=2, strides=2, padding="same")(y)
y = Convolution2D(
filters=128,
kernel_size=3,
strides=1,
padding="same",
activation="relu",
kernel_initializer="he_normal")(y)
y = Convolution2D(
filters=128,
kernel_size=3,
strides=1,
padding="same",
activation="relu",
kernel_initializer="he_normal")(y)
y = MaxPooling2D(pool_size=2, strides=2, padding="same")(y)
y = Convolution2D(
filters=256,
kernel_size=3,
strides=1,
padding="same",
activation="relu",
kernel_initializer="he_normal")(y)
y = Convolution2D(
filters=256,
kernel_size=3,
strides=1,
padding="same",
activation="relu",
kernel_initializer="he_normal")(y)
y = MaxPooling2D(pool_size=2, strides=2, padding="same")(y)
y = Flatten()(y)
y = Dropout(self.config.get("dropout", 0.5))(y)
y = Dense(
units=10, activation="softmax", kernel_initializer="he_normal")(y)
model = Model(inputs=x, outputs=y, name="model1")
return model