rising.random¶
Random Parameter Injection Base Classes¶
-
class
rising.random.abstract.
AbstractParameter
(*args, **kwargs)[source][source]¶ Bases:
torch.nn.Module
Abstract Parameter class to inject randomness to transforms
-
static
_get_n_samples
(size=(1, ))[source][source]¶ Calculates the number of elements in the given size
-
forward
(size=None, device=None, dtype=None, tensor_like=None)[source][source]¶ Forward function (will also be called if the module is called). Calculates the number of samples from the given shape, performs the sampling and converts it back to the correct shape.
- Parameters
size (
Union
[Sequence
,Size
,None
]) – the size of the sampled values. If None, it samples one value without reshapingdevice (
Union
[device
,str
,None
]) – the device the result value should be set to, if it is a tensordtype (
Union
[dtype
,str
,None
]) – the dtype, the result value should be casted to, if it is a tensortensor_like (
Optional
[Tensor
]) – the tensor, having the correct dtype and device. The result will be pushed onto this device and casted to this dtype if this is specified.
- Returns
the sampled values
- Return type
list or torch.Tensor
Notes
if the parameter
tensor_like
is given, it overwrites the parametersdtype
anddevice
-
static
AbstractParameter¶
-
class
rising.random.abstract.
AbstractParameter
(*args, **kwargs)[source][source] Bases:
torch.nn.Module
Abstract Parameter class to inject randomness to transforms
-
static
_get_n_samples
(size=(1, ))[source][source] Calculates the number of elements in the given size
-
forward
(size=None, device=None, dtype=None, tensor_like=None)[source][source] Forward function (will also be called if the module is called). Calculates the number of samples from the given shape, performs the sampling and converts it back to the correct shape.
- Parameters
size (
Union
[Sequence
,Size
,None
]) – the size of the sampled values. If None, it samples one value without reshapingdevice (
Union
[device
,str
,None
]) – the device the result value should be set to, if it is a tensordtype (
Union
[dtype
,str
,None
]) – the dtype, the result value should be casted to, if it is a tensortensor_like (
Optional
[Tensor
]) – the tensor, having the correct dtype and device. The result will be pushed onto this device and casted to this dtype if this is specified.
- Returns
the sampled values
- Return type
list or torch.Tensor
Notes
if the parameter
tensor_like
is given, it overwrites the parametersdtype
anddevice
-
abstract
sample
(n_samples)[source][source] Abstract sampling function
- Parameters
n_samples (
int
) – the number of samples to return- Returns
the sampled values
- Return type
torch.Tensor or list
-
static
Continuous Random Parameters¶
-
class
rising.random.continuous.
ContinuousParameter
(distribution)[source][source]¶ Bases:
rising.random.abstract.AbstractParameter
Class to perform parameter sampling from torch distributions
- Parameters
distribution (
Distribution
) – the distribution to sample from
-
class
rising.random.continuous.
NormalParameter
(mu, sigma)[source][source]¶ Bases:
rising.random.continuous.ContinuousParameter
Samples Parameters from a normal distribution. For details have a look at
torch.distributions.Normal
-
class
rising.random.continuous.
UniformParameter
(low, high)[source][source]¶ Bases:
rising.random.continuous.ContinuousParameter
Samples Parameters from a uniform distribution. For details have a look at
torch.distributions.Uniform
ContinuousParameter¶
-
class
rising.random.continuous.
ContinuousParameter
(distribution)[source][source] Bases:
rising.random.abstract.AbstractParameter
Class to perform parameter sampling from torch distributions
- Parameters
distribution (
Distribution
) – the distribution to sample from
NormalParameter¶
-
class
rising.random.continuous.
NormalParameter
(mu, sigma)[source][source] Bases:
rising.random.continuous.ContinuousParameter
Samples Parameters from a normal distribution. For details have a look at
torch.distributions.Normal
UniformParameter¶
-
class
rising.random.continuous.
UniformParameter
(low, high)[source][source] Bases:
rising.random.continuous.ContinuousParameter
Samples Parameters from a uniform distribution. For details have a look at
torch.distributions.Uniform
Discrete Random Parameters¶
-
class
rising.random.discrete.
DiscreteParameter
(population, replacement=False, weights=None, cum_weights=None)[source][source]¶ Bases:
rising.random.abstract.AbstractParameter
Samples parameters from a discrete population with or without replacement
- Parameters
-
class
rising.random.discrete.
DiscreteCombinationsParameter
(population, replacement=False)[source][source]¶ Bases:
rising.random.discrete.DiscreteParameter
Sample parameters from an extended population which consists of all possible combinations of the given population
DiscreteParameter¶
-
class
rising.random.discrete.
DiscreteParameter
(population, replacement=False, weights=None, cum_weights=None)[source][source] Bases:
rising.random.abstract.AbstractParameter
Samples parameters from a discrete population with or without replacement
- Parameters
DiscreteCombinationsParameter¶
-
class
rising.random.discrete.
DiscreteCombinationsParameter
(population, replacement=False)[source][source] Bases:
rising.random.discrete.DiscreteParameter
Sample parameters from an extended population which consists of all possible combinations of the given population