tf.split(input, num_split, dimension):
dimension指输入张量的哪一个维度,如果是0就表示对第0维度进行切割;num_split就是切割的数量,如果是2就表示输入张量被切成2份,每一份是一个列表。
例如:
import tensorflow as tf; import numpy as np; A = [[1,2,3],[4,5,6]] x = tf.split(A, 3, 1) with tf.Session() as sess: c = sess.run(x) for ele in c: print( ele )
输出:
[[1]
[4]]
[[2]
[5]]
[[3]
[6]]