x1_concat = tf.concat([ws11_x1, ws12_x1, ws130_x1], 3)
x2_concat = tf.concat([ws11_x2, ws12_x2, ws130_x2], 3)
x1_flat = tf.reshape(x1_concat, [-1, 1, 3, 100])
x2_flat = tf.reshape(x2_concat, [-1, 1, 3, 100])
regM_matmul = tf.matmul(x1_flat, x2_flat, transpose_a=True)
feah = []
for batch in range(50):
feah.append(tf.diag_part(regM_matmul[batch][0]))
feah_flat = tf.reshape(feah,[-1,1,1,100])
return feah_flat
2、 algorithm 2中的feaa同样也只用cos函数结果表示相似度。
def cul_feaa_sim(ws11_x1, ws11_x2, ws12_x1, ws12_x2, ws130_x1, ws130_x2):
x1_concat = tf.concat([ws11_x1, ws12_x1, ws130_x1], 3)
x2_concat = tf.concat([ws11_x2, ws12_x2, ws130_x2], 3)
x1_flat = tf.reshape(x1_concat, [-1, 1, 3, 100])
x2_flat = tf.reshape(x2_concat, [-1, 1, 3, 100])
regM_matmul = tf.matmul(x1_flat, x2_flat, transpose_b=True)
feaa = tf.reshape(regM_matmul,[-1,1,1,9])
return feaa
在1、和2、中,卷积和池化的tensor的变化如上图所示,得到的max池化方式的tensor的shape是[batch,1,,1,filter_nums],其他池化方式一样。参照下图对各种池化方式计算相似度的直观描述,可以推测出具体的返回结果feah和feaa的shape。 、
3、而algorithm 2中的feab的卷积方式就和图二不同,而是如下图所示: