Random number helpers (varipeps.utils.random)
Utility functions for initialize tensors randomly
- class varipeps.utils.random.PEPS_Jax_Random(seed: int | None = None)
Bases:
PEPS_Random_ImplJax implementation for the random number generator.
- Parameters:
seed (
int, optional) – Seed for the generator.Default:None- block(dim: Sequence[int], dtype: Type[number], *, normalize: bool = True) Array
Generate a tensor with random numbers.
- Parameters:
dim (sequence of
int) – Sequence with the dimensions of the tensordtype (
numpy.dtypeorjax.numpy.dtype) – Dtype of the generated tensors
- Keyword Arguments:
normalize (
bool, optional) – Flag if the generated tensors are normalized. Defaults to True.Default:True- Returns:
Tensor with random numbers and the specified shape.
- Return type:
- class varipeps.utils.random.PEPS_Numpy_Random(seed: int | None = None)
Bases:
PEPS_Random_ImplNumpy implementation for the random number generator.
- Parameters:
seed (
int, optional) – Seed for the generator.Default:None- block(dim: Sequence[int], dtype: Type[number], *, normalize: bool = True) ndarray
Generate a tensor with random numbers.
- Parameters:
dim (sequence of
int) – Sequence with the dimensions of the tensordtype (
numpy.dtypeorjax.numpy.dtype) – Dtype of the generated tensors
- Keyword Arguments:
normalize (
bool, optional) – Flag if the generated tensors are normalized. Defaults to True.Default:True- Returns:
Tensor with random numbers and the specified shape.
- Return type:
- class varipeps.utils.random.PEPS_Random_Impl
Bases:
ABCAbstract base class for random number generator implementation.
- abstractmethod block(dim: Sequence[int], dtype: Type[number], *, normalize: bool = True) ndarray | Array
Generate a tensor with random numbers.
- Parameters:
dim (sequence of
int) – Sequence with the dimensions of the tensordtype (
numpy.dtypeorjax.numpy.dtype) – Dtype of the generated tensors
- Keyword Arguments:
normalize (
bool, optional) – Flag if the generated tensors are normalized. Defaults to True.Default:True- Returns:
Tensor with random numbers and the specified shape.
- Return type:
- class varipeps.utils.random.PEPS_Random_Number_Generator
Bases:
objectClass to maintain a global instance of random number generators
- classmethod destroy_state() None
Destroy the current state of the random number generator.
- classmethod get_generator(seed: int | None = None, *, backend: str = 'jax') PEPS_Random_Impl
Class method to obtain the instance of the random number generator for the specific backend
- Parameters:
seed (
int, optional) – Seed for the random number generator. If there is already a instance of the generator, this parameter is ignored.Default:None- Keyword Arguments:
backend (
str, optional) – Backend which should be used as random number generator. May bejaxornumpy. Defaults tojax.