【问题标题】:Product two 3D tensor in Keras在 Keras 中乘积两个 3D 张量
【发布时间】:2019-02-10 02:51:38
【问题描述】:

我有两个 3 维的张量:

 tensor 1 (bs1, sent_len1, emb_dim)
 tensor 2 (bs2, sent_len2, emb_dim)

bs1 和 bs2 是未知的,它们不一定相等。

我想对这些张量进行乘积以获得如下输出:

 output (bs1, bs2, sent_len2, sent_len1)

【问题讨论】:

    标签: python keras deep-learning artificial-intelligence


    【解决方案1】:

    像这样使用 K.dot():

    t2t = K.permute_dimensions(tensor2, [0, 2, 1])  # (bs2, emb_dim, sent_len2)
    output = K.dot(tensor1, t2t)  # (bs1, sent_len1, bs2, sent_len2)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-01
      • 2019-11-08
      • 2019-09-22
      • 2021-03-05
      • 2019-01-07
      • 2019-11-26
      • 1970-01-01
      • 2019-03-27
      相关资源
      最近更新 更多