towhee.hub.builtin.operators.tensor_like.tensor_random¶
- class towhee.hub.builtin.operators.tensor_like.tensor_random(shape)[source]¶
Bases:
object
Return a random tensor filled with random numbers from [0.0, 1.0).
- Parameters:
shape ([int], optional) – tensor shape. Defaults to None.
- Returns:
output tensor.
- Return type:
ndarray
Examples:
>>> import numpy as np >>> from towhee import dc >>> df = dc['a'](range(3)) >>> df.tensor_random['a', 'b'](shape = [2, 1]).map(lambda x: x.b.shape).to_list() [(2, 1), (2, 1), (2, 1)]
>>> df.to_column() >>> df.tensor_random['a', 'c'](shape = [2, 1])['c'].map(lambda x: x.shape).to_list() [(2, 1), (2, 1), (2, 1)]
Methods
Attributes
metainfo
- __call__(*args, **kws)¶
Call self as a function.