Tensorο
- class nuTens.tensor.Tensorο
Bases:
pybind11_objectTensor 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, indices: 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, indices: 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β¦
- unsqueeze(self: nuTens._pyNuTens.tensor.Tensor, dim: int) nuTens._pyNuTens.tensor.Tensorο
add an extra dimension to this tensor at the specified location
- 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