mindspore.dataset.transforms.Concatenate

class mindspore.dataset.transforms.Concatenate(axis=0, prepend=None, append=None)[source]

Tensor operation that concatenates all columns into a single tensor, only 1D tenspr is supported.

Parameters
  • axis (int, optional) – Concatenate the tensors along given axis (Default=0).

  • prepend (numpy.array, optional) – NumPy array to be prepended to the already concatenated tensors (Default=None).

  • append (numpy.array, optional) – NumPy array to be appended to the already concatenated tensors (Default=None).

Raises
  • TypeError – If axis is not of type int.

  • TypeError – If prepend is not of type numpy.ndarray.

  • TypeError – If append is not of type numpy.ndarray.

Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> # concatenate string
>>> prepend_tensor = np.array(["dw", "df"], dtype='S')
>>> append_tensor = np.array(["dwsdf", "df"], dtype='S')
>>> concatenate_op = transforms.Concatenate(0, prepend_tensor, append_tensor)
>>> data = [["This","is","a","string"]]
>>> dataset = ds.NumpySlicesDataset(data)
>>> dataset = dataset.map(operations=concatenate_op)