2

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 ?

enter image description here

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)
Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55
Soad Saleh
  • 83
  • 7
  • It may be better if you first test your code and then tell us what your problem is rather than just posting the code and asking if there is any problem with the code. – Pedram Mar 19 '18 at 21:39
  • how to select the max vector of uni_gram & bi_gram & tri_gram – Soad Saleh Mar 20 '18 at 02:15

0 Answers0