【问题标题】:Concat tensors in tensorflow TF 2.0张量流 TF 2.0 中的连接张量
【发布时间】:2021-05-17 21:44:21
【问题描述】:

我有两个张量 os 形状 [2,1,30] 和 [2,181,30]。我想将它们附加为 [2,182,30] 的形状。有什么想法可以实现吗?

我不能使用tf.concattf.stack,因为它们都会导致错误

tensorflow.python.framework.errors_impl.InvalidArgumentError: ConcatOp : Dimensions of inputs should match: shape[0] = [2,1,30] vs. shape[1] = [2,181,30]
         [[{{node concat}}]]

【问题讨论】:

    标签: stack append concatenation tensorflow2.0 tensor


    【解决方案1】:

    你可能没有为tf.concat指定坐标轴

    a = tf.random.normal(shape=[2,1,30])
    b = tf.random.normal(shape=[2, 181, 30])
    
    c = tf.concat([a,b], axis=1)
    

    【讨论】:

      猜你喜欢
      • 2019-08-13
      • 2018-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-01
      • 2017-11-05
      • 2019-05-19
      • 2019-04-09
      相关资源
      最近更新 更多