# TensorFlow函数：tf.sparse_concat

## tf.sparse_concat 函数

``````sparse_concat(
axis,
sp_inputs,
name=None,
expand_nonconcat_dim=False,
concat_dim=None
)``````

indices,values 和 shapes 列表必须具有相同的长度.

``````sp_inputs[0]: shape = [2, 3]
[0, 2]: "a"
[1, 0]: "b"
[1, 1]: "c"

sp_inputs[1]: shape = [2, 4]
[0, 1]: "d"
[0, 2]: "e"``````

``````shape = [2, 7]
[0, 2]: "a"
[0, 4]: "d"
[0, 5]: "e"
[1, 0]: "b"
[1, 1]: "c"``````

``````[    a] concat [  d e  ] = [    a   d e  ]
[b c  ]        [       ]   [b c          ]``````

``````sp_inputs[0]: shape = [3, 3]
[0, 2]: "a"
[1, 0]: "b"
[2, 1]: "c"

sp_inputs[1]: shape = [2, 4]
[0, 1]: "d"
[0, 2]: "e"``````

``````shape = [3, 7]
[0, 2]: "a"
[0, 4]: "d"
[0, 5]: "e"
[1, 0]: "b"
[2, 1]: "c"``````

``````[    a] concat [  d e  ] = [    a   d e  ]
[b    ]        [       ]   [b            ]
[  c  ]                    [  c          ]``````

• axis：连接沿着的维度.必须在范围 [-rank,rank)中,其中rank是每个输入 SparseTensor 中的维数.
• sp_inputs：SparseTensor要连接的列表.
• name：返回张量的名称前缀(可选).
• expand_nonconcat_dim：是否允许扩展非连续的维度.默认为False.
• concat_dim：轴的旧(已弃用)名称.

tf.sparse_concat函数返回具有连接输出的 SparseTensor.

• TypeError：如果 sp_inputs 不是一个 SparseTensor 列表,则引发此异常.

App下载