问题
I'm trying to implement this description and that what I did I generated uni_gram & bi_gram & tri_gram of shape(?,15,512) "using padding " & then for each word I concatenate the three feature vector (?,3,512) and then I apply to them Globalmaxpooling1D I do not know if I implemented it well or not so can any one help me ?
Q = Input(shape=(15,))
V = Input(shape=(512,196))
word_level = Embedding ( vocab_size , 512 , input_length=max_length)(Q)
uni_gram = Conv1D( 512 , kernel_size = 1 , activation='tanh' ,
padding='same' )(word_level)
bi_gram = Conv1D( 512 , kernel_size = 2 , activation='tanh' ,
padding='same' )(word_level)
tri_gram = Conv1D( 512 , kernel_size = 3 , activation='tanh' ,
padding='same' )(word_level)
phrases = []
for w in range(0,max_length):
Uni =uni_gram [:,w,:]
Uni= tf.reshape(Uni , [-1,1,512 ])
Bi = bi_gram [:,w,:]
Bi = tf.reshape(Bi , [-1,1,512 ])
Tri= tri_gram [:,w,:]
Tri = tf.reshape( Tri , [-1,1,512 ])
Uni_Bi_Tri = Concatenate(axis=1)([ Uni, Bi , Tri ])
Best_phrase = GlobalMaxPooling1D()(Uni_Bi_Tri)
Best_phrase = tf.reshape( Best_phrase , [-1,1,512 ])
phrases.append(Best_phrase)
来源:https://stackoverflow.com/questions/49371157/what-is-the-kind-of-max-pooling-in-this-nlp-questionhierarchy-description