amplfi.train module
- class amplfi.train.augmentations.PsdEstimator(length, sample_rate, fftlength, overlap=None, average='mean', fast=True)[source]
Bases:
ModuleModule that takes a sample of data, splits it into two unequal-length segments, calculates the PSD of the first section, then returns this PSD along with the second section.
- Parameters:
length (
float) – The length, in seconds, of timeseries data to be returned for whitening. Note that the length of time used for the PSD will then be whatever remains along first part of the time axis of the input.sample_rate (
float) – Rate at which input data has been sampled in Hzfftlength (
float) – Length of FFTs to use when computing the PSDoverlap (
Optional[float]) – Amount of overlap between FFT windows when computing the PSD. Default value of None uses fftlength / 2average (
str) – Method for aggregating spectra from FFT windows, either “mean” or “median”fast (
bool) – If True, use a slightly faster PSD algorithm that is inaccurate for the lowest two frequency bins. If you plan on highpassing later, this should be fine.
- class amplfi.train.losses.VICRegLoss(lambda_param=25.0, mu_param=25.0, nu_param=1.0, eps=0.0001, max_std=1.0)[source]
Bases:
ModuleImplementation of the VICReg loss [0].
This implementation is based on the code published by the authors [1].
[0] VICReg, 2022, https://arxiv.org/abs/2105.04906
- lambda_param
Scaling coefficient for the invariance term of the loss.
- mu_param
Scaling coefficient for the variance term of the loss.
- nu_param
Scaling coefficient for the covariance term of the loss.
- eps
Epsilon for numerical stability.
- amplfi.train.losses.invariance_loss(x, y)[source]
Returns VICReg invariance loss.
- Parameters:
x (
Tensor) – Tensor with shape (batch_size, …, dim).y (
Tensor) – Tensor with shape (batch_size, …, dim).
- Return type:
Tensor- Returns:
The computed VICReg invariance loss.
- amplfi.train.losses.variance_loss(x, eps=0.0001, max_std=1.0)[source]
Returns VICReg variance loss.
- Parameters:
x (
Tensor) – Tensor with shape (batch_size, …, dim).eps (
float) – Epsilon for numerical stability.
- Return type:
Tensor- Returns:
The computed VICReg variance loss.
- amplfi.train.losses.covariance_loss(x)[source]
Returns VICReg covariance loss.
Generalized version of the covariance loss with support for tensors with more than two dimensions. Adapted from VICRegL: https://github.com/facebookresearch/VICRegL/blob/803ae4c8cd1649a820f03afb4793763e95317620/main_vicregl.py#L299
- Parameters:
x (
Tensor) – Tensor with shape (batch_size, …, dim).- Return type:
Tensor- Returns:
The computed VICReg covariance loss.
- class amplfi.train.prior.ParameterTransformer(**transforms)[source]
Bases:
ModuleHelper class for applying preprocessing transformations to inference parameters
- amplfi.train.models module
FlowModelFlowModel.forward()FlowModel.training_step()FlowModel.validation_step()FlowModel.on_predict_epoch_start()FlowModel.on_test_epoch_start()FlowModel.on_test_batch_end()FlowModel.analyze_event()FlowModel.test_step()FlowModel.predict_step()FlowModel.cast_as_bilby_result()FlowModel.filter_parameters()FlowModel.configure_callbacks()
SimilarityModel