sbi.neural_nets.classifier_nn

Navigation

sbi.neural_nets.classifier_nn#

classifier_nn(model, z_score_theta='independent', z_score_x='independent', hidden_features=50, embedding_net_theta=Identity(), embedding_net_x=Identity(), **kwargs)[source]#

Returns a function that builds a classifier for learning density ratios.

This function will usually be used for SNRE. The returned function is to be passed to the inference class when using the flexible interface.

Note that in the view of the SNRE classifier we build below, x=theta and y=x.

Parameters:
  • model (str) – The type of classifier that will be created. One of [linear, mlp, resnet].

  • z_score_theta (Literal['independent', 'structured', 'transform_to_unconstrained', 'none'] | None) – Whether to z-score parameters \(\theta\) before passing them into the network, can take one of the following: - none, or None: do not z-score. - independent: z-score each dimension independently. - structured: treat dimensions as related, therefore compute mean and std over the entire batch, instead of per-dimension. Should be used when each sample is, for example, a time series or an image.

  • z_score_x (Literal['independent', 'structured', 'transform_to_unconstrained', 'none'] | None) – Whether to z-score simulation outputs \(x\) before passing them into the network, same options as z_score_theta.

  • hidden_features (int) – Number of hidden features.

  • embedding_net_theta (Module) – Optional embedding network for parameters \(\theta\).

  • embedding_net_x (Module) – Optional embedding network for simulation outputs \(x\). This embedding net allows to learn features from potentially high-dimensional simulation outputs.

  • **kwargs (Any) – Additional classifier arguments. Valid keys are defined by ClassifierConfig; unknown keys trigger a warning and are forwarded to the builder.

Return type:

Callable