quick_tensor

# Import statement

from hottbox.utils.generation import quick_tensor
quick_tensor(shape, base='arange')[source]

Simplified creation of generic tensor

Parameters
shapetuple

Desired shape of the tensor

basestr

Id of base function that generates values for the tensor. If not one from {"arange", "randn", "rand", "ones"} then np.arange will be used.

Returns
tensorTensor

Examples

>>> from hottbox.utils.generation import quick_tensor
>>> tensor = quick_tensor(shape=(2, 3, 4))
>>> print(tensor)
    This tensor is of order 3 and consists of 24 elements.
    Sizes and names of its modes are (2, 3, 4) and ['mode-0', 'mode-1', 'mode-2'] respectively.
>>> print(tensor.data)
    [[[ 0  1  2  3]
      [ 4  5  6  7]
      [ 8  9 10 11]]
     [[12 13 14 15]
      [16 17 18 19]
      [20 21 22 23]]]
>>> tensor = quick_tensor(shape=(2, 3, 4), base="ones")
>>> print(tensor)
    This tensor is of order 3 and consists of 24 elements.
    Sizes and names of its modes are (2, 3, 4) and ['mode-0', 'mode-1', 'mode-2'] respectively.
>>> print(tensor.data)
    [[[1. 1. 1. 1.]
      [1. 1. 1. 1.]
      [1. 1. 1. 1.]]
     [[1. 1. 1. 1.]
      [1. 1. 1. 1.]
      [1. 1. 1. 1.]]]