我正在尝试实现此描述以及我所做的 我生成了uni_gram& bi_gram&形状三角形(?,15,512)“使用填充” &安培;然后对于每个单词我连接三个特征向量(?,3,512) 然后我向他们申请Globalmaxpooling1D我不知道我是否实施得好,所以任何人都可以帮助我吗?
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)