concat() is to connect the tensors along the specified dimension. Among them, tensorflow version 1.3 is defined as follows:
concat(values,axis,name='concat')
1. For 2 dimensions, 0 represents rows and 1 represents columns
t1 = [[1, 2, 3], [4, 5, 6]] t2 = [[7, 8, 9], [10, 11, 12]] with () as sess: print((([t1, t2], 0) ))
The results are: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
t1 = [[1, 2, 3], [4, 5, 6]] t2 = [[7, 8, 9], [10, 11, 12]] with () as sess: print((([t1, t2], 1) ))
The result is: [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]
2. For 3 dimensions, 0 means vertical, 1 means row, and 2 means column
t1 = [[[1, 1, 1],[2, 2, 2]],[[3, 3, 3],[4, 4, 4]]] t2 = [[[5, 5, 5],[6, 6, 6]],[[7, 7, 7],[8, 8, 8]]] with () as sess: print((([t1, t2], 0) ))
Results: [[[1 1 1],[2 2 2]] , [[3 3 3],[4 4 4]] , [[5 5 5],[6 6 6]] , [[7 7 7],[8 8 8]]]
Tensor("concat_30:0", shape=(4, 2, 3), dtype=int32)
The result of axis=1 is as follows:
Tensor("concat_31:0", shape=(2, 4, 3), dtype=int32)
[[[1 1 1], [2 2 2],[5 5 5],[6 6 6]], [[3 3 3], [4 4 4],[7 7 7], [8 8 8]]]
The result of axis=2 is as follows:
Tensor("concat_32:0", shape=(2, 2, 6), dtype=int32)
[[[1 1 1 5 5 5],[2 2 2 6 6 6]], [[3 3 3 7 7 7], [4 4 4 8 8 8]]]
The above brief discussion on the use of () in tensorflow is all the content I share with you. I hope you can give you a reference and I hope you can support me more.