Tensorο
- class nuTens.tensor.Tensorο
Bases:
pybind11_object
Tensor defines a basic interface for creating and manipulating tensors.To create tensors you should use the static constructor methods. Alternatively you can chain together multiple property setters.
For example
from nuTens.tensor import Tensor, dtype tensor = Tensor.ones([3,3], dtype.scalar_type.float, dtype.device_type.cpu)
will get you a 3x3 tensor of floats that lives on the CPU.
This is equivalent to
- abs(self: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Get element-wise magnitudes of a complex tensor
- add_batch_dim(self: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Add a batch dimension to the start of this tensor if it doesnβt have one already
- angle(self: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Get element-wise phases of a complex tensor
- backward(self: nuTens._pyNuTens.tensor.Tensor) None ο
Do the backward propagation from this tensor
- conj(self: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Get complex conjugate of a complex tensor
- device(self: nuTens._pyNuTens.tensor.Tensor, new_device: nuTens._pyNuTens.dtype.device_type) nuTens._pyNuTens.tensor.Tensor ο
Set the device that the tensor lives on
- static diag(diagonal: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Create a tensor with specified values along the diagonal
- dtype(self: nuTens._pyNuTens.tensor.Tensor, new_dtype: nuTens._pyNuTens.dtype.scalar_type) nuTens._pyNuTens.tensor.Tensor ο
Set the data type of the tensor
- static eye(n: int, dtype: nuTens._pyNuTens.dtype.scalar_type = <scalar_type.float: 1>, device: nuTens._pyNuTens.dtype.device_type = <device_type.cpu: 0>, requires_grad: bool = True) nuTens._pyNuTens.tensor.Tensor ο
Create a tensor initialised with an identity matrix
- static from_torch_tensor(arg0: torch.Tensor) nuTens._pyNuTens.tensor.Tensor ο
construct a nuTens Tensor from a pytorch tensor
- get_shape(self: nuTens._pyNuTens.tensor.Tensor) list[int] ο
Get the shape of this tensor
- get_value(self: nuTens._pyNuTens.tensor.Tensor, arg0: list[int]) int | float | float | complex | complex ο
Get the data stored at a particular index of the tensor
- get_values(self: nuTens._pyNuTens.tensor.Tensor, arg0: list[int | str]) nuTens._pyNuTens.tensor.Tensor ο
Get the subset of values in this tensor at a specified location
- grad(self: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Get the accumulated gradient stored in this tensor after calling backward()
- has_batch_dim(*args, **kwargs)ο
Overloaded function.
has_batch_dim(self: nuTens._pyNuTens.tensor.Tensor) -> bool
Check Whether or not the first dimension should be interpreted as a batch dim for this tensor
has_batch_dim(self: nuTens._pyNuTens.tensor.Tensor, new_value: bool) -> nuTens._pyNuTens.tensor.Tensor
Set Whether or not the first dimension should be interpreted as a batch dim for this tensor
- imag(self: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Get imaginary part of a complex tensor
- static ones(shape: list[int], dtype: nuTens._pyNuTens.dtype.scalar_type = <scalar_type.float: 1>, device: nuTens._pyNuTens.dtype.device_type = <device_type.cpu: 0>, requires_grad: bool = True) nuTens._pyNuTens.tensor.Tensor ο
Create a tensor initialised with ones
- static rand(shape: list[int], dtype: nuTens._pyNuTens.dtype.scalar_type = <scalar_type.float: 1>, device: nuTens._pyNuTens.dtype.device_type = <device_type.cpu: 0>, requires_grad: bool = True) nuTens._pyNuTens.tensor.Tensor ο
Create a tensor initialised with random values
- real(self: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Get real part of a complex tensor
- requires_grad(self: nuTens._pyNuTens.tensor.Tensor, new_value: bool) nuTens._pyNuTens.tensor.Tensor ο
Set Whether or not this tensor requires gradient to be calculated
- set_value(*args, **kwargs)ο
Overloaded function.
set_value(self: nuTens._pyNuTens.tensor.Tensor, indices: nuTens._pyNuTens.tensor.Tensor, value: nuTens._pyNuTens.tensor.Tensor) -> None
Set a value at a specific index of this tensor
set_value(self: nuTens._pyNuTens.tensor.Tensor, indices: list[Union[int, str]], value: nuTens._pyNuTens.tensor.Tensor) -> None
Set a value at a specific index of this tensor
set_value(self: nuTens._pyNuTens.tensor.Tensor, indices: list[int], value: float) -> None
Set a value at a specific index of this tensor
set_value(self: nuTens._pyNuTens.tensor.Tensor, indices: list[int], value: float) -> None
Set a value at a specific index of this tensor
set_value(self: nuTens._pyNuTens.tensor.Tensor, indices: list[int], value: complex) -> None
Set a value at a specific index of this tensor
set_value(self: nuTens._pyNuTens.tensor.Tensor, indices: list[int], value: complex) -> None
Set a value at a specific index of this tensor
- to_string(self: nuTens._pyNuTens.tensor.Tensor) str ο
get a summary of this tensor as a string
- torch_tensor(self: nuTens._pyNuTens.tensor.Tensor) torch.Tensor ο
Get the pytorch tensor that lives inside this tensor. Only available if using the pytorch backendβ¦
- static zeros(shape: list[int], dtype: nuTens._pyNuTens.dtype.scalar_type = <scalar_type.float: 1>, device: nuTens._pyNuTens.dtype.device_type = <device_type.cpu: 0>, requires_grad: bool = True) nuTens._pyNuTens.tensor.Tensor ο
Create a tensor initialised with zeros
- nuTens.tensor.cos(t1: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Element-wise trigonometric cosine function
- nuTens.tensor.cumsum(t1: nuTens._pyNuTens.tensor.Tensor, dimensions: int) nuTens._pyNuTens.tensor.Tensor ο
Get the cumulative sum over particular dimensions
- nuTens.tensor.div(t1: nuTens._pyNuTens.tensor.Tensor, t2: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Element-wise division
- nuTens.tensor.exp(t1: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Take element-wise exponential of a tensor
- nuTens.tensor.matmul(t1: nuTens._pyNuTens.tensor.Tensor, t2: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Matrix multiplication
- nuTens.tensor.mul(t1: nuTens._pyNuTens.tensor.Tensor, t2: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Element-wise multiplication
- nuTens.tensor.outer(t1: nuTens._pyNuTens.tensor.Tensor, t2: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Tensor outer product
- nuTens.tensor.pow(*args, **kwargs)ο
Overloaded function.
pow(t1: nuTens._pyNuTens.tensor.Tensor, power: float) -> nuTens._pyNuTens.tensor.Tensor
Raise to scalar power
pow(t1: nuTens._pyNuTens.tensor.Tensor, power: complex) -> nuTens._pyNuTens.tensor.Tensor
Raise to scalar power
- nuTens.tensor.scale(*args, **kwargs)ο
Overloaded function.
scale(t1: nuTens._pyNuTens.tensor.Tensor, scalar: float) -> nuTens._pyNuTens.tensor.Tensor
Scalar multiplication
scale(t1: nuTens._pyNuTens.tensor.Tensor, scalar: complex) -> nuTens._pyNuTens.tensor.Tensor
Scalar multiplication
- nuTens.tensor.sin(t1: nuTens._pyNuTens.tensor.Tensor) nuTens._pyNuTens.tensor.Tensor ο
Element-wise trigonometric sine function
- nuTens.tensor.sum(*args, **kwargs)ο
Overloaded function.
sum(t1: nuTens._pyNuTens.tensor.Tensor) -> nuTens._pyNuTens.tensor.Tensor
Get the sum of all values in a tensor
sum(t1: nuTens._pyNuTens.tensor.Tensor, dimensions: list[int]) -> nuTens._pyNuTens.tensor.Tensor
Get the sum over particular dimensions
- nuTens.tensor.transpose(t1: nuTens._pyNuTens.tensor.Tensor, index_1: int, index_2: int) nuTens._pyNuTens.tensor.Tensor ο
Get the matrix transpose