tf.split

View source on GitHub

Splits a tensor into sub tensors.

tf.split(
    value, num_or_size_splits, axis=0, num=None, name='split'
)

If num_or_size_splits is an integer, then value is split along dimension axis into num_split smaller tensors. This requires that num_split evenly divides value.shape[axis].

If num_or_size_splits is a 1-D Tensor (or list), we call it size_splits and value is split into len(size_splits) elements. The shape of the i-th element has the same size as the value except along dimension axis where the size is size_splits[i].

For example:

# 'value' is a tensor with shape [5, 30]
# Split 'value' into 3 tensors with sizes [4, 15, 11] along dimension 1
split0, split1, split2 = tf.split(value, [4, 15, 11], 1)
tf.shape(split0)  # [5, 4]
tf.shape(split1)  # [5, 15]
tf.shape(split2)  # [5, 11]
# Split 'value' into 3 tensors along dimension 1
split0, split1, split2 = tf.split(value, num_or_size_splits=3, axis=1)
tf.shape(split0)  # [5, 10]

Args:

Returns:

if num_or_size_splits is a scalar returns num_or_size_splits Tensor objects; if num_or_size_splits is a 1-D Tensor returns num_or_size_splits.get_shape[0] Tensor objects resulting from splitting value.

Raises: