【问题标题】:How to concatenate two vectors of different dimensions如何连接两个不同维度的向量
【发布时间】:2017-12-04 20:47:33
【问题描述】:

如果 X = [[ 1. 1. 1. 1. 1. 1.]] 和 Y = [[ 0. 0. 0. 0.]] - 我如何连接这两个向量以形成一个向量沿列?

我做了以下但没有用:

import tensorflow as tf
X = tf.constant(1.0, shape=[1, 6])
Y = tf.zeros(shape=[1,4])
XY = tf.concat((X,Y), axis = 0)
sess = tf.Session()
print(sess.run(XY))

【问题讨论】:

  • 你的意思是获取形状为[1, 10]的向量吗?

标签: python tensorflow


【解决方案1】:

如果你想在轴 0 上连接它们,那么它们的大小必须相等

假设你不想要它,

你需要在tf.concat方法中设置axis = 1

【讨论】:

    猜你喜欢
    • 2022-01-22
    • 2021-12-09
    • 2018-10-29
    • 2021-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    相关资源
    最近更新 更多