synference.custom_runner

Custom runner like LtU-ILI’s SBIRunner, but with Optuna-based hyperparam optimization.

Classes

class synference.custom_runner.CustomIndependentUniform(*args, device='cpu', **kwargs)[source]

A wrapper around CustomUniform to create an independent distribution.

class synference.custom_runner.CustomUniform(low, high, name_list, verbose=True, validate_args=None, report_threshold=0.1)[source]

Custom Uniform distribution with enhanced validation.

A custom Uniform distribution that accepts a list of parameter names for enhanced validation error messages, especially for batched data.

It generates uniformly distributed random samples from the half-open interval [low, high).

Parameters:
  • low (float or Tensor) – Lower range (inclusive).

  • high (float or Tensor) – Upper range (exclusive).

  • name_list (List[str]) – A list of names for each parameter dimension. Its length must match the number of parameters.

  • validate_args (bool, optional) – Whether to validate arguments. Defaults to Distribution._validate_args.

  • report_threshold (float, optional) – Threshold for reporting validation errors. Defaults to 0.1.

cdf(value)[source]

Cumulative distribution function.

Return type:

Tensor

entropy()[source]

Returns the differential entropy of the distribution.

Return type:

Tensor

expand(batch_shape, _instance=None)[source]

Expands the distribution to the desired batch shape.

Return type:

CustomUniform

icdf(value)[source]

Inverse of the CDF function.

Return type:

Tensor

log_prob(value)[source]

Log probability density function.

Return type:

Tensor

property mean: Tensor

Returns the mean of the distribution.

property mode: Tensor

Returns the mode of the distribution. For a uniform distribution, this is undefined.

rsample(sample_shape=())[source]

Generates a sample_shape shaped reparameterized sample.

Return type:

Tensor

property stddev: Tensor

Returns the standard deviation of the distribution.

property support: Constraint

Returns the support constraint with validation if verbose is True.

property variance: Tensor

Returns the variance of the distribution.

class synference.custom_runner.Interval(lower_bound, upper_bound, validate_func=None)[source]

Constrain to a real interval [lower_bound, upper_bound].

check(value)[source]

Check if the value is within the interval.

class synference.custom_runner.SBICustomRunner(prior, engine, net_configs, embedding_net=Identity(), train_args={}, out_dir=None, device='cpu', proposal=None, name='', signatures=None)[source]

Runner for SBI inference which uses a custom training loop with Optuna-based optimization.

classmethod from_config(config_path, **kwargs)[source]

Create an instance of SBICustomRunner from a configuration file.

Return type:

SBICustomRunner