rising.random¶
Random Parameter Injection Base Classes¶
- class rising.random.abstract.AbstractParameter(*args, **kwargs)[source][source]¶
Bases:
ModuleAbstract 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_likeis given, it overwrites the parametersdtypeanddevice
AbstractParameter¶
- class rising.random.abstract.AbstractParameter(*args, **kwargs)[source][source]¶
Bases:
ModuleAbstract 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_likeis given, it overwrites the parametersdtypeanddevice
Continuous Random Parameters¶
- class rising.random.continuous.ContinuousParameter(distribution)[source][source]¶
Bases:
AbstractParameterClass 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:
ContinuousParameterSamples Parameters from a normal distribution. For details have a look at
torch.distributions.Normal
- class rising.random.continuous.UniformParameter(low, high)[source][source]¶
Bases:
ContinuousParameterSamples Parameters from a uniform distribution. For details have a look at
torch.distributions.Uniform
ContinuousParameter¶
- class rising.random.continuous.ContinuousParameter(distribution)[source][source]¶
Bases:
AbstractParameterClass 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:
ContinuousParameterSamples 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:
ContinuousParameterSamples Parameters from a uniform distribution. For details have a look at
torch.distributions.Uniform
Discrete Random Parameters¶
- class rising.random.discrete.DiscreteCombinationsParameter(population, replacement=False)[source][source]¶
Bases:
DiscreteParameterSample parameters from an extended population which consists of all possible combinations of the given population
- class rising.random.discrete.DiscreteParameter(population, replacement=False, weights=None, cum_weights=None)[source][source]¶
Bases:
AbstractParameterSamples parameters from a discrete population with or without replacement
- Parameters
DiscreteParameter¶
- class rising.random.discrete.DiscreteParameter(population, replacement=False, weights=None, cum_weights=None)[source][source]¶
Bases:
AbstractParameterSamples parameters from a discrete population with or without replacement
- Parameters
DiscreteCombinationsParameter¶
- class rising.random.discrete.DiscreteCombinationsParameter(population, replacement=False)[source][source]¶
Bases:
DiscreteParameterSample parameters from an extended population which consists of all possible combinations of the given population