towhee.hub.builtin.operators.tensor_like.tensor_stack

class towhee.hub.builtin.operators.tensor_like.tensor_stack(axis=0)[source]

Bases: object

Stack the sequence of inputs along a new axis.

Parameters:

axis (int, optional) – the axis of the result array along which the inputs are stacked. Defaults to 0.

Returns:

the stacked array.

Return type:

ndarray

Examples:

>>> import numpy as np
>>> from towhee.functional import DataCollection
>>> dc = (
...     DataCollection.range(10)
...         .map(lambda x: np.array([x]))
...         .batch(2)
...         .tensor_stack(axis=1)
... )
>>> dc.to_list()
[array([[0, 1]]), array([[2, 3]]), array([[4, 5]]), array([[6, 7]]), array([[8, 9]])]

Methods

Attributes

metainfo

__call__(*args, **kws)

Call self as a function.

__init__(axis=0)[source]