本文整理匯總了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