From c1535b941bd13677f6f055a3a42b704d8c49a901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Knaebel?= Date: Fri, 28 Jul 2017 17:25:08 +0200 Subject: [PATCH] remove max pooling from models for better infromation flow --- models/renes_networks.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/models/renes_networks.py b/models/renes_networks.py index db786f5..0d72c07 100644 --- a/models/renes_networks.py +++ b/models/renes_networks.py @@ -1,6 +1,7 @@ import keras from keras.engine import Input, Model -from keras.layers import Embedding, Conv1D, GlobalMaxPooling1D, Dense, Dropout, TimeDistributed, MaxPool1D +from keras.layers import Embedding, Conv1D, GlobalMaxPooling1D, Dense, Dropout, TimeDistributed, MaxPool1D, \ + GlobalAveragePooling1D def get_embedding(vocab_size, embedding_size, input_length, @@ -8,12 +9,13 @@ def get_embedding(vocab_size, embedding_size, input_length, x = y = Input(shape=(input_length,)) y = Embedding(input_dim=vocab_size, output_dim=embedding_size)(y) y = Conv1D(filter_size, kernel_size=5, activation='relu')(y) - y = MaxPool1D(pool_size=3, strides=1)(y) + # NOTE: max pooling destroys information flow for embedding + # y = MaxPool1D(pool_size=3, strides=1)(y) y = Conv1D(filter_size, kernel_size=3, activation='relu')(y) - y = MaxPool1D(pool_size=3, strides=1)(y) + # y = MaxPool1D(pool_size=3, strides=1)(y) y = Conv1D(filter_size, kernel_size=3, activation='relu')(y) - y = GlobalMaxPooling1D()(y) - y = Dropout(drop_out)(y) + y = GlobalAveragePooling1D()(y) + # y = Dropout(drop_out)(y) y = Dense(hidden_dims, activation="relu")(y) return Model(x, y)