|TensorFlow 2 version||View source on GitHub|
Splits a tensor into sub tensors.
tf.split( value, num_or_size_splits, axis=0, num=None, name='split' )
num_or_size_splits is an integer, then
value is split along dimension
num_split smaller tensors. This requires that
num_or_size_splits is a 1-D Tensor (or list), we call it
value is split into
len(size_splits) elements. The shape of the
element has the same size as the
value except along dimension
the size is
# '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]
num_or_size_splits: Either an integer indicating the number of splits along split_dim or a 1-D integer
Tensoror Python list containing the sizes of each output tensor along split_dim. If a scalar then it must evenly divide
value.shape[axis]; otherwise the sum of sizes along the split dimension must match that of the
axis: An integer or scalar
Tensor. The dimension along which to split. Must be in the range
[-rank(value), rank(value)). Defaults to 0.
num: Optional, used to specify the number of outputs when it cannot be inferred from the shape of
name: A name for the operation (optional).
num_or_size_splits is a scalar returns
num_or_size_splits is a 1-D Tensor returns
Tensor objects resulting from splitting
numis unspecified and cannot be inferred.