Random number helpers (varipeps.utils.random)
Utility functions for initialize tensors randomly
- class varipeps.utils.random.PEPS_Jax_Random(seed: int | None = None)[source]
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[source]
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)[source]
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[source]
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[source]
Bases:
ABCAbstract base class for random number generator implementation.
- abstractmethod block(dim: Sequence[int], dtype: Type[number], *, normalize: bool = True) ndarray | Array[source]
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[source]
Bases:
objectClass to maintain a global instance of random number generators
- classmethod get_generator(seed: int | None = None, *, backend: str = 'jax') PEPS_Random_Impl[source]
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.Default:'jax'- Returns:
Instance of random number generator implementation.
- Return type:
PEPS_Jax_RandomorPEPS_Numpy_Random