【问题标题】:How to merge two sub-networks into a model in tensorflow如何在tensorflow中将两个子网络合并成一个模型
【发布时间】:2019-04-03 15:25:00
【问题描述】:

我需要设计一个包含两个子网络的深度网络。

1- The first network: (sub_net_1)
input_1 size: 128x128x1
output_1 size: 512x512x1

from elsewhere:
input_2 size: 512x512x4


concatenate(output_1, input_2)

2- The second network: (sub_net_2)
input_3 size: 512x512x5

我需要将 output_1 与相同大小的 input_2 连接起来并馈送到网络

我知道在 tensorflow 中定义模型的简单方法是 模型(输入=输入,输出=x​​) 当我有两个不同大小的输入并且需要一起训练两个子网络时,如何为我的问题定义模型?

这里是网络的架构:https://imgur.com/OQFhlPW

【问题讨论】:

  • 所以 sub_net_2 的输入应该是 (512, 512, 2) 的形状?
  • sub_net_2 的输入是 (512, 512, 5),即连接大小为 (512, 512, 1) 的 sub_net_1 的输出和大小为 (512, 512, 4) 的 input_2 的输出
  • tf.concat([sub_net_1, input_2], axis=2)

标签: python tensorflow model deep-learning


【解决方案1】:

也许您可以使用 concatenate() 函数并将结果作为输入传递给子网_2:

concat = concatenate([output_1, input_2])
input_3()(concat)

查看示例:https://www.depends-on-the-definition.com/lstm-with-char-embeddings-for-ner/

【讨论】:

    猜你喜欢
    • 2019-01-19
    • 1970-01-01
    • 1970-01-01
    • 2019-01-02
    • 1970-01-01
    • 2018-12-20
    • 2020-03-13
    • 2023-03-30
    • 1970-01-01
    相关资源
    最近更新 更多