【问题标题】:Concat two 2D tensors连接两个 2D 张量
【发布时间】:2019-06-26 01:27:47
【问题描述】:

我有一个足够简单的 TensorFlow 操作需要执行,但我想不出该怎么做。

目前,我的数据采用以下格式的张量:

[[a0], [a1], [a2], ...]

我想将该数据转换为以下格式:

[[1-a0, a0], [1-a1, a1], [1-a2, a2], ...]

可能有一个非常简单的解决方案,但我缺乏发现的词汇 - 如果我能找到它,我将不胜感激。

【问题讨论】:

    标签: python python-3.x tensorflow tensor


    【解决方案1】:

    我觉得你可以用tf.concat:

    tf.concat([1 - x, x], axis=1)
    # <tf.Tensor 'concat:0' shape=(3, 2) dtype=int32>
    

    【讨论】:

      猜你喜欢
      • 2021-11-20
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 2021-01-30
      • 2017-12-05
      • 1970-01-01
      • 2021-04-04
      • 2020-09-26
      相关资源
      最近更新 更多