如何在张量流中融合两种不同的模型

时间:2019-01-29 11:24:30

标签: tensorflow

我建立包含两个不同cnn模型的模型,一个是vggnet,另一个是文本cnn模型,通常,vggnet模型的更新要比文本cnn模型花费更多的时间,但是我不确定这两个模型是否已更新同步,或者应该如何确保这两个模型更新同步。

我的模型图:

my model graph

我的代码:

 # multimodal (fusing text output and image output)
    image_model_drop = tf.nn.dropout(image_model_out, self.dropout_keep_prob)
    image_linear = tf.nn.xw_plus_b(image_model_drop, self.embed_image_w, self.embed_image_b)
    image_emb = tf.nn.relu(image_linear)

    with tf.control_dependencies([image_emb]):
        text_model_drop = tf.nn.dropout(text_model_out, self.dropout_keep_prob)
        text_linear = tf.nn.xw_plus_b(text_model_drop, self.embed_text_w, self.embed_text_b)
        text_emb = tf.nn.relu(text_linear)


    fusing_output = tf.multiply(text_emb, image_emb)

0 个答案:

没有答案