amplfi.train.models module
- class amplfi.train.models.flow.FlowModel(*args, arch, filter_params=True, samples_per_event=10000, min_samples_per_pix_dist=5, max_samples_per_pixel=20, target_prior=None, crossmatch=True, create_pp_plot=True, **kwargs)[source]
Bases:
AmplfiModelA LightningModule for training normalizing flows
- Parameters:
*args – See arguments in amplfi.train.models.base.AmplfiModel
arch (
FlowArchitecture) – Neural network architecture to train. This should be a subclass of FlowArchitecture.filter_params (
bool) – If True, filter the samples produced by the flow to keep only valid samples within the prior boundaries.samples_per_event (
int) – Number of samples to draw per event for testingmin_samples_per_pix_dist (
int)max_samples_per_pixel (
int)crossmatch (
bool) – If True, run ligo.skymap.postprocess.crossmatch on result objects at the end of testing epoch and produce searched area and volume cdfstarget_prior (
Optional[Path]) – Path to a bilby prior file for reweighting posterior samples to a new prior.
- analyze_event(strain, asds, parameters=None, snr=None, gpstime=None)[source]
- Return type:
tuple[AmplfiResult,Optional[AmplfiResult]]
- test_step(batch, _)[source]
- Return type:
tuple[AmplfiResult,Optional[AmplfiResult]]
- predict_step(batch, _)[source]
- Return type:
tuple[AmplfiResult,Optional[AmplfiResult]]
- cast_as_bilby_result(samples, log_probs, log_prior_probs, injection_parameters=None)[source]
Cast posterior samples as Bilby Result object for ease of producing corner and pp plots
- Parameters:
samples (
ndarray) – An array of posterior samples of shape (1, num_samples, num_params)log_probs (
ndarray) – An array of log probabilities of posterior samples as predicted under the normalizing flow modellog_prior_probs (
ndarray) – An array of log prior probabilities of posterior samples as predicted under the training priorinjection_parameters (
Optional[dict[str,float]]) – For injections, a dictionary mapping from parameter string to the true injection value
- Return type:
- class amplfi.train.models.similarity.SimilarityModel(*args, arch, similarity_loss, **kwargs)[source]
Bases:
AmplfiModelA LightningModule for training similarity embeddings
- Parameters:
arch (
SimilarityEmbedding) – A neural network architecture that maps waveforms to lower dimensional embedded space