fastbnns.simulation package

Submodules

fastbnns.simulation.generators module

Collections of data generators to, e.g., aid dataset creation.

class fastbnns.simulation.generators.Generator(simulator: Callable, simulator_kwargs: dict, simulator_kwargs_generator: dict)[source]

Bases: Module

Generator to allow calling simulator with stochastic inputs.

forward() Any[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

fastbnns.simulation.generators.sample_simulator(simulator: Callable, simulator_kwargs_generator: dict, simulator_kwargs: dict) dict[source]

Call simulator with randomly sampled inputs.

Parameters:
  • simulator – Callable that accepts keyword arguments and returns simulated data.

  • simulator_kwargs_generator – Dictionary whose keys define keyword arguments of simulator and whose values are Callable and return valid values of associated keyword arguments.

  • simulator_kwargs – Fixed keyword arguments to be merged with arguments generated by simulator_kwargs_generator before passing to simulator.

fastbnns.simulation.images module

fastbnns.simulation.observation module

Functionality for simulating observations of random variables.

class fastbnns.simulation.observation.NoiseTransform(noise_fxn: Callable, noise_fxn_kwargs: dict = {}, noise_fxn_kwargs_generator: dict = {})[source]

Bases: Module

Wrapper to facilitate using noise functions with torch transform functionality.

forward(x: tensor) tensor[source]

Forward pass to generate noisy x.

fastbnns.simulation.observation.add_read_noise(signal: tensor, sigma: tensor) tensor[source]

Noisy realization of signal (read noise).

Parameters:
  • signal – Clean signal to which we add zero-mean Normal read noise.

  • sigma – Standard deviation of zero-mean Normally distributed read noise. Can be homoscedastic (scalar) or heteroscedastic (array matching len(signal)).

fastbnns.simulation.observation.sensor_noise(signal: tensor, sigma: tensor) tensor[source]

Noisy realization of signal (read noise + shot noise).

Parameters:
  • signal – Clean signal to which we add read noise and shot noise.

  • sigma – Standard deviation of zero mean Normally distributed read noise. Can be homoscedastic (scalar) or heteroscedastic (array matching len(signal)).

fastbnns.simulation.polynomials module

Functionality for simulating polynomial data.

fastbnns.simulation.polynomials.polynomial(x: tensor, coefficients: Iterable = [0.0, 1.0]) tensor[source]

Basic polynomial.

Parameters:
  • x – Points at which to evaluate the polynomial.

  • coefficients – Polynomial coefficients in ascending order.

Module contents