GeneratorMixture#

class deepinv.physics.generator.GeneratorMixture(generators: List[PhysicsGenerator], probs: List[float], rng: Generator | None = None)[source]#

Bases: PhysicsGenerator

Base class for mixing multiple PhysicsGenerator.

The mixture randomly selects a subset of batch elements to be generated by each generator according to the probabilities given in the constructor.

Parameters:


Examples:

Mixing two types of blur

>>> from deepinv.physics.generator import MotionBlurGenerator, DiffractionBlurGenerator
>>> from deepinv.physics.generator import GeneratorMixture
>>> _ = torch.manual_seed(0)
>>> g1 = MotionBlurGenerator(psf_size = (3, 3), num_channels = 1)
>>> g2 = DiffractionBlurGenerator(psf_size = (3, 3), num_channels = 1)
>>> generator = GeneratorMixture([g1, g2], [0.5, 0.5])
>>> params_dict = generator.step(batch_size=1)
>>> print(params_dict.keys())
dict_keys(['filter'])
step(batch_size: int = 1, seed: int | None = None, **kwargs)[source]#

Returns a new set of physics’ parameters, according to the probabilities given in the constructor.

Parameters:
  • batch_size (int) – the number of samples to generate.

  • seed (int) – the seed for the random number generator.

Returns:

A dictionary with the new parameters, ie {param_name: param_value}.

Examples using GeneratorMixture:#

A tour of blur operators

A tour of blur operators