flint.tensor¶
- class flint.Tensor(data: Union[float, list, numpy.ndarray], depends_on: list = [], requires_grad: bool = False)[source]¶
 Bases:
objectTensor is the basic structure in the computation graph. It holds value for forward computation and grad for backward propagation.
- Parameters
 data (Union[float, list, np.ndarray]) – Data for the Tensor
depends_on (list, optional, default=[]) – List of dependent tensors (used when building autograd graph)
requires_grad (bool, optional, default=False) – Whether the Tensor requires gradient
- add_depends_on(depends_on: list = []) None[source]¶
 Add the dependent tensors for building autograd graph.
- Parameters
 depends_on (list) – List of dependent tensors
- argmax(dim: Optional[int] = None) flint.tensor.Tensor[source]¶
 Return the indice of the maximum value of all elements in the tensor.
- property dtype¶
 
- fill_(val: float) None[source]¶
 Fill the tensor with the given scalar value
val.- Parameters
 val (float) – The value to fill the tensor with
- log_softmax(dim: int = - 1) flint.tensor.Tensor[source]¶
 
- max(dim: Optional[int] = None, keepdims: bool = False) flint.tensor.Tensor[source]¶
 Return the maximum value of all elements in the tensor.
- property ndim: int¶
 Return the number of dimensions of
selftensor, alias fordim().
- normal_(mean: float = 0.0, std: float = 1.0) None[source]¶
 Fill the tensor with values drawn from the normal distribution.
- Parameters
 mean (float, optional, default=0.) – The mean of the normal distribution
std (float, optional, default=1.) – The standard deviation of the normal distribution
- property numel: int¶
 Return the total number of elements in the
selftensor, i.e., the product of the tensor’s dimensions.
- permute(*dims) flint.tensor.Tensor[source]¶
 Return a view of the original tensor with its dimensions permuted.
- Parameters
 *dims – The desired ordering of dimensions
- property shape: Tuple[int]¶
 Return the size of the
selftensor, alias forsize().
- softmax(dim: int = - 1) flint.tensor.Tensor[source]¶
 
- squeeze(dim: Optional[int] = None) flint.tensor.Tensor[source]¶
 Remove the dimensions of input of size 1.
- Parameters
 dim (int, optional) – If given, the input will be squeezed only in this dimension. Or all the dimensions of size 1 will be removed.
- sum(dim: Optional[int] = None, keepdims: bool = False) flint.tensor.Tensor[source]¶
 
- transpose(dim0: int, dim1: int) flint.tensor.Tensor[source]¶
 Swap the dimension dim0 and dim1 of the tensor.
- Parameters
 dim0 (int) – The first dimension to be transposed
dim1 (int) – The second dimension to be transposed
- uniform_(low: float = 0.0, high: float = 1.0) None[source]¶
 Fill the tensor with values drawn from the uniform distribution.
- Parameters
 low (float, optional, default=0.) – The lower bound of the uniform distribution
high (float, optional, default=1.) – The upper bound of the uniform distribution
- unsqueeze(dim: int) flint.tensor.Tensor[source]¶
 Insert a dimension of size one at the specified position.
- Parameters
 dim (int) – The index at which to insert the singleton dimension
- view(*shape) flint.tensor.Tensor[source]¶
 Return a new tensor with the same data as the self tensor but of a different shape.
- Parameters
 *shape – The desired size