鍍金池/ 問答/人工智能  Python  HTML/ tensorflow 不同維度的 tensor 如何合并?

tensorflow 不同維度的 tensor 如何合并?

我的 scv 文件中每行一個樣本,假設(shè)一個樣本只有兩個特征 x1, x2。
reader 按行讀之后可以用 tf.stack 合并成 [x1, x2]
現(xiàn)在想要將所有的樣本合并成一個 m*2 的 tensor,也就是這樣:
[[x1^(1), x2^(1)]
[x1^(2), x2^(2)]
...
[x1^(m), x2^(m)]]
但是不同維度的 tensor 好像無法合并..
比如:
[[x1^(1), x2^(1)]
[x1^(2), x2^(2)]]

[[x1^(3), x2^(3)]]
合并會報錯:
From merging shape 0 with other shapes. for 'stack_1' (op: 'Pack') with input shapes: [2,2], [1,2].
求解...

回答
編輯回答
幼梔

新建axis時有用stack,在原有的某axis上拼接用concat

2017年7月16日 07:11