本文整理汇总了Python中keras.layers.pooling.GlobalMaxPooling1D方法的典型用法代码示例。如果您正苦于以下问题:Python pooling.GlobalMaxPooling1D方法的具体用法?Python pooling.GlobalMaxPooling1D怎么用?Python pooling.GlobalMaxPooling1D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras.layers.pooling
的用法示例。
在下文中一共展示了pooling.GlobalMaxPooling1D方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_globalpooling_1d
# 需要导入模块: from keras.layers import pooling [as 别名]
# 或者: from keras.layers.pooling import GlobalMaxPooling1D [as 别名]
def test_globalpooling_1d():
layer_test(pooling.GlobalMaxPooling1D,
input_shape=(3, 4, 5))
layer_test(pooling.GlobalAveragePooling1D,
input_shape=(3, 4, 5))
示例2: cnn_model
# 需要导入模块: from keras.layers import pooling [as 别名]
# 或者: from keras.layers.pooling import GlobalMaxPooling1D [as 别名]
def cnn_model(self, params):
"""
Method builds uncompiled intent_model of shallow-and-wide CNN
Args:
params: disctionary of parameters for NN
Returns:
Uncompiled intent_model
"""
if type(self.opt['kernel_sizes_cnn']) is str:
self.opt['kernel_sizes_cnn'] = [int(x) for x in
self.opt['kernel_sizes_cnn'].split(' ')]
inp = Input(shape=(params['text_size'], params['embedding_size']))
outputs = []
for i in range(len(params['kernel_sizes_cnn'])):
output_i = Conv1D(params['filters_cnn'], kernel_size=params['kernel_sizes_cnn'][i],
activation=None,
kernel_regularizer=l2(params['coef_reg_cnn']),
padding='same')(inp)
output_i = BatchNormalization()(output_i)
output_i = Activation('relu')(output_i)
output_i = GlobalMaxPooling1D()(output_i)
outputs.append(output_i)
output = concatenate(outputs, axis=1)
output = Dropout(rate=params['dropout_rate'])(output)
output = Dense(params['dense_size'], activation=None,
kernel_regularizer=l2(params['coef_reg_den']))(output)
output = BatchNormalization()(output)
output = Activation('relu')(output)
output = Dropout(rate=params['dropout_rate'])(output)
output = Dense(self.n_classes, activation=None,
kernel_regularizer=l2(params['coef_reg_den']))(output)
output = BatchNormalization()(output)
act_output = Activation('sigmoid')(output)
model = Model(inputs=inp, outputs=act_output)
return model
示例3: dcnn_model
# 需要导入模块: from keras.layers import pooling [as 别名]
# 或者: from keras.layers.pooling import GlobalMaxPooling1D [as 别名]
def dcnn_model(self, params):
"""
Method builds uncompiled intent_model of deep CNN
Args:
params: disctionary of parameters for NN
Returns:
Uncompiled intent_model
"""
if type(self.opt['kernel_sizes_cnn']) is str:
self.opt['kernel_sizes_cnn'] = [int(x) for x in
self.opt['kernel_sizes_cnn'].split(' ')]
if type(self.opt['filters_cnn']) is str:
self.opt['filters_cnn'] = [int(x) for x in
self.opt['filters_cnn'].split(' ')]
inp = Input(shape=(params['text_size'], params['embedding_size']))
output = inp
for i in range(len(params['kernel_sizes_cnn'])):
output = Conv1D(params['filters_cnn'][i], kernel_size=params['kernel_sizes_cnn'][i],
activation=None,
kernel_regularizer=l2(params['coef_reg_cnn']),
padding='same')(output)
output = BatchNormalization()(output)
output = Activation('relu')(output)
output = MaxPooling1D()(output)
output = GlobalMaxPooling1D()(output)
output = Dropout(rate=params['dropout_rate'])(output)
output = Dense(params['dense_size'], activation=None,
kernel_regularizer=l2(params['coef_reg_den']))(output)
output = BatchNormalization()(output)
output = Activation('relu')(output)
output = Dropout(rate=params['dropout_rate'])(output)
output = Dense(self.n_classes, activation=None,
kernel_regularizer=l2(params['coef_reg_den']))(output)
output = BatchNormalization()(output)
act_output = Activation('sigmoid')(output)
model = Model(inputs=inp, outputs=act_output)
return model