dipas.backends module
- class dipas.backends.Backend(*args, **kwds)
Bases:
Generic
[_TensorType
,_ParameterType
]- ModuleType: ClassVar[Type]
- ParameterType: ClassVar[Type]
- TensorType: ClassVar[Type]
- as_float64(x: _TensorType) _TensorType
Convert the given tensor’s data representation to float64.
- as_parameter(x: _TensorType) _ParameterType
Transform the given tensor to a parameter.
- concatenate(xs: Union[List[_TensorType], Tuple[_TensorType, ...]], *, dim: int = 0) _TensorType
Concatenate multiple tensors along one of their dimensions.
- from_numbers(value: Union[float, Sequence[Union[float, Sequence[Union[float, Sequence[float]]]]]]) _TensorType
Create a new tensor from the given number(s).
- from_numpy(array: <MagicMock name='mock.ndarray' id='139745953275856'>) _TensorType
Create a new tensor from the given numpy array.
- functions: _Functions[_TensorType]
- ignore_gradient: Callable[[], AbstractContextManager]
- linalg: _Linalg[_TensorType]
- make_id_matrix(n: int) _TensorType
Create a new tensor representing the nxn identity matrix.
- make_zeros(*shape: int) _TensorType
Create a new tensor of the given shape, filled with zeros.
- random: _Random[_TensorType]
- requires_grad(x: _TensorType) bool
Check whether the given tensor requires gradient tracking.
- stack(xs: Union[List[_TensorType], Tuple[_TensorType, ...]], *, dim: int = 0) _TensorType
Stack multiple tensors along a new dimension.
- to_number(x: _TensorType) float
Convert the given 0-dim tensor to a float object.
- to_numpy(x: _TensorType) <MagicMock name='mock.ndarray' id='139745953275856'>
Convert the given tensor to a numpy array.
- transpose(x: _TensorType) _TensorType
Transpose the given tensor by swapping the (0,1) dimensions.
- update_tensor_data(x: _TensorType, new_value: _TensorType) None
Update the underlying tensor data while ignoring any gradient tracking.
- zeros_like(x: _TensorType) _TensorType
Create a new tensor of same shape as the given tensor, filled will zeros.
- class dipas.backends.Numpy
Bases:
Backend
[<MagicMock name=’mock.ndarray’ id=’139745953275856’>, <MagicMock name=’mock.ndarray’ id=’139745953275856’>]- ModuleType
alias of
ModuleProxy
- ParameterType: ClassVar[Type] = <MagicMock name='mock.ndarray' id='139745953275856'>
- TensorType: ClassVar[Type] = <MagicMock name='mock.ndarray' id='139745953275856'>
- as_float64(x: <MagicMock name='mock.ndarray' id='139745953275856'>) <MagicMock name='mock.ndarray' id='139745953275856'>
Convert the given tensor’s data representation to float64.
- as_parameter(x: <MagicMock name='mock.ndarray' id='139745953275856'>) <MagicMock name='mock.ndarray' id='139745953275856'>
Transform the given tensor to a parameter.
- concatenate(xs: ~typing.Union[~typing.List[<MagicMock name='mock.ndarray' id='139745953275856'>], ~typing.Tuple[<MagicMock name='mock.ndarray' id='139745953275856'>, ...]], *, dim: int = 0) <MagicMock name='mock.ndarray' id='139745953275856'>
Concatenate multiple tensors along one of their dimensions.
- from_numbers(value: Union[float, Sequence[Union[float, Sequence[Union[float, Sequence[float]]]]]]) <MagicMock name='mock.ndarray' id='139745953275856'>
Create a new tensor from the given number(s).
- from_numpy(array: <MagicMock name='mock.ndarray' id='139745953275856'>) <MagicMock name='mock.ndarray' id='139745953275856'>
Create a new tensor from the given numpy array.
- functions: _Functions[_TensorType]
- ignore_gradient: Callable[[], AbstractContextManager]
- linalg: _Linalg[_TensorType]
- make_id_matrix(n: int) <MagicMock name='mock.ndarray' id='139745953275856'>
Create a new tensor representing the nxn identity matrix.
- make_zeros(*shape: int) <MagicMock name='mock.ndarray' id='139745953275856'>
Create a new tensor of the given shape, filled with zeros.
- random: _Random[_TensorType]
- requires_grad(x: <MagicMock name='mock.ndarray' id='139745953275856'>) bool
Check whether the given tensor requires gradient tracking.
- stack(xs: ~typing.Union[~typing.List[<MagicMock name='mock.ndarray' id='139745953275856'>], ~typing.Tuple[<MagicMock name='mock.ndarray' id='139745953275856'>, ...]], *, dim: int = 0) <MagicMock name='mock.ndarray' id='139745953275856'>
Stack multiple tensors along a new dimension.
- to_number(x: <MagicMock name='mock.ndarray' id='139745953275856'>) float
Convert the given 0-dim tensor to a float object.
- to_numpy(x: <MagicMock name='mock.ndarray' id='139745953275856'>) <MagicMock name='mock.ndarray' id='139745953275856'>
Convert the given tensor to a numpy array.
- transpose(x: <MagicMock name='mock.ndarray' id='139745953275856'>) <MagicMock name='mock.ndarray' id='139745953275856'>
Transpose the given tensor by swapping the (0,1) dimensions.
- update_tensor_data(x: <MagicMock name='mock.ndarray' id='139745953275856'>, new_value: <MagicMock name='mock.ndarray' id='139745953275856'>) None
Update the underlying tensor data while ignoring any gradient tracking.
- zeros_like(x: <MagicMock name='mock.ndarray' id='139745953275856'>) <MagicMock name='mock.ndarray' id='139745953275856'>
Create a new tensor of same shape as the given tensor, filled will zeros.
- class dipas.backends.PyTorch
Bases:
Backend
[<MagicMock name=’mock.Tensor’ id=’139745955357904’>, <MagicMock name=’mock.nn.Parameter’ id=’139745955712976’>]- ModuleType
alias of
object
- ParameterType: ClassVar[Type] = <MagicMock name='mock.nn.Parameter' id='139745955712976'>
- TensorType: ClassVar[Type] = <MagicMock name='mock.Tensor' id='139745955357904'>
- as_float64(x: <MagicMock name='mock.Tensor' id='139745955357904'>) <MagicMock name='mock.Tensor' id='139745955357904'>
Convert the given tensor’s data representation to float64.
- as_parameter(x: <MagicMock name='mock.Tensor' id='139745955357904'>) <MagicMock name='mock.nn.Parameter' id='139745955712976'>
Transform the given tensor to a parameter.
- concatenate(xs: ~typing.Union[~typing.List[<MagicMock name='mock.Tensor' id='139745955357904'>], ~typing.Tuple[<MagicMock name='mock.Tensor' id='139745955357904'>, ...]], *, dim: int = 0) <MagicMock name='mock.Tensor' id='139745955357904'>
Concatenate multiple tensors along one of their dimensions.
- from_numbers(value: Union[float, Sequence[Union[float, Sequence[Union[float, Sequence[float]]]]]]) <MagicMock name='mock.Tensor' id='139745955357904'>
Create a new tensor from the given number(s).
- from_numpy(array: <MagicMock name='mock.ndarray' id='139745953275856'>) <MagicMock name='mock.Tensor' id='139745955357904'>
Create a new tensor from the given numpy array.
- functions: _Functions[_TensorType]
- ignore_gradient: Callable[[], AbstractContextManager]
- linalg: _Linalg[_TensorType]
- make_id_matrix(n: int) <MagicMock name='mock.Tensor' id='139745955357904'>
Create a new tensor representing the nxn identity matrix.
- make_zeros(*shape: int) <MagicMock name='mock.Tensor' id='139745955357904'>
Create a new tensor of the given shape, filled with zeros.
- random: _Random[_TensorType]
- requires_grad(x: <MagicMock name='mock.Tensor' id='139745955357904'>) bool
Check whether the given tensor requires gradient tracking.
- stack(xs: ~typing.Union[~typing.List[<MagicMock name='mock.Tensor' id='139745955357904'>], ~typing.Tuple[<MagicMock name='mock.Tensor' id='139745955357904'>, ...]], *, dim: int = 0) <MagicMock name='mock.Tensor' id='139745955357904'>
Stack multiple tensors along a new dimension.
- to_number(x: <MagicMock name='mock.Tensor' id='139745955357904'>) float
Convert the given 0-dim tensor to a float object.
- to_numpy(x: <MagicMock name='mock.Tensor' id='139745955357904'>) <MagicMock name='mock.ndarray' id='139745953275856'>
Convert the given tensor to a numpy array.
- transpose(x: <MagicMock name='mock.Tensor' id='139745955357904'>) <MagicMock name='mock.Tensor' id='139745955357904'>
Transpose the given tensor by swapping the (0,1) dimensions.
- update_tensor_data(x: <MagicMock name='mock.Tensor' id='139745955357904'>, new_value: <MagicMock name='mock.Tensor' id='139745955357904'>) None
Update the underlying tensor data while ignoring any gradient tracking.
- zeros_like(x: <MagicMock name='mock.Tensor' id='139745955357904'>) <MagicMock name='mock.Tensor' id='139745955357904'>
Create a new tensor of same shape as the given tensor, filled will zeros.