sbi/inference/snpe/snpe_base.py
Killed 56 out of 85 mutantsTimeouts
Mutants that made the test suite take a lot longer so the tests were killed.Mutant 270
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -352,7 +352,7 @@
)
epoch, self._val_log_prob = 0, float("-Inf")
- while epoch <= max_num_epochs and not self._converged(epoch, stop_after_epochs):
+ while epoch <= max_num_epochs or not self._converged(epoch, stop_after_epochs):
# Train for a single epoch.
self._posterior.net.train()
Survived
Survived mutation testing. These mutants show holes in your test suite.Mutant 211
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -86,7 +86,7 @@
self._build_neural_net = utils.posterior_nn(model=density_estimator)
else:
self._build_neural_net = density_estimator
- self._posterior = None
+ self._posterior = ""
self._sample_with_mcmc = sample_with_mcmc
self._mcmc_method = mcmc_method
Mutant 212
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -87,7 +87,7 @@
else:
self._build_neural_net = density_estimator
self._posterior = None
- self._sample_with_mcmc = sample_with_mcmc
+ self._sample_with_mcmc = None
self._mcmc_method = mcmc_method
self._prior_masks, self._model_bank = [], []
Mutant 213
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -88,7 +88,7 @@
self._build_neural_net = density_estimator
self._posterior = None
self._sample_with_mcmc = sample_with_mcmc
- self._mcmc_method = mcmc_method
+ self._mcmc_method = None
self._prior_masks, self._model_bank = [], []
Mutant 218
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -158,7 +158,7 @@
if calibration_kernel is None:
calibration_kernel = lambda x: ones([len(x)])
- max_num_epochs = 2 ** 31 - 1 if max_num_epochs is None else max_num_epochs
+ max_num_epochs = 3 ** 31 - 1 if max_num_epochs is None else max_num_epochs
num_sims_per_round = self._ensure_list(num_simulations_per_round, num_rounds)
Mutant 219
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -158,7 +158,7 @@
if calibration_kernel is None:
calibration_kernel = lambda x: ones([len(x)])
- max_num_epochs = 2 ** 31 - 1 if max_num_epochs is None else max_num_epochs
+ max_num_epochs = 2 * 31 - 1 if max_num_epochs is None else max_num_epochs
num_sims_per_round = self._ensure_list(num_simulations_per_round, num_rounds)
Mutant 220
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -158,7 +158,7 @@
if calibration_kernel is None:
calibration_kernel = lambda x: ones([len(x)])
- max_num_epochs = 2 ** 31 - 1 if max_num_epochs is None else max_num_epochs
+ max_num_epochs = 2 ** 32 - 1 if max_num_epochs is None else max_num_epochs
num_sims_per_round = self._ensure_list(num_simulations_per_round, num_rounds)
Mutant 221
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -158,7 +158,7 @@
if calibration_kernel is None:
calibration_kernel = lambda x: ones([len(x)])
- max_num_epochs = 2 ** 31 - 1 if max_num_epochs is None else max_num_epochs
+ max_num_epochs = 2 ** 31 + 1 if max_num_epochs is None else max_num_epochs
num_sims_per_round = self._ensure_list(num_simulations_per_round, num_rounds)
Mutant 222
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -158,7 +158,7 @@
if calibration_kernel is None:
calibration_kernel = lambda x: ones([len(x)])
- max_num_epochs = 2 ** 31 - 1 if max_num_epochs is None else max_num_epochs
+ max_num_epochs = 2 ** 31 - 2 if max_num_epochs is None else max_num_epochs
num_sims_per_round = self._ensure_list(num_simulations_per_round, num_rounds)
Mutant 227
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -166,7 +166,7 @@
# Run simulations for the round.
theta, x, prior_mask = self._run_simulations(round_, num_sims)
- x_shape = x_shape_from_simulation(x)
+ x_shape = None
# First round or if retraining from scratch:
# Call the `self._build_neural_net` with the rounds' thetas and xs as
Mutant 238
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -217,7 +217,7 @@
# things to tensorboard anymore. Calling `leakage_correction()` is needed
# to update the leakage after each round.
if self._posterior.default_x is None:
- acceptance_rate = torch.tensor(float("nan"))
+ acceptance_rate = None
else:
acceptance_rate = self._posterior.leakage_correction(
x=self._posterior.default_x,
Mutant 240
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -241,7 +241,6 @@
self._posterior._num_trained_rounds = num_rounds
return self._posterior
- @abstractmethod
def _log_prob_proposal_posterior(
self, theta: Tensor, x: Tensor, masks: Tensor, **kwargs
) -> Tensor:
Mutant 246
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -288,7 +288,7 @@
active and `patience` is not enough to reach it.
"""
- prior_mask_values = ones if round_ == 0 else zeros
+ prior_mask_values = ones if round_ != 0 else zeros
return prior_mask_values((num_simulations, 1), dtype=torch.bool)
def _train(
Mutant 247
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -288,7 +288,7 @@
active and `patience` is not enough to reach it.
"""
- prior_mask_values = ones if round_ == 0 else zeros
+ prior_mask_values = ones if round_ == 1 else zeros
return prior_mask_values((num_simulations, 1), dtype=torch.bool)
def _train(
Mutant 249
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -289,7 +289,7 @@
"""
prior_mask_values = ones if round_ == 0 else zeros
- return prior_mask_values((num_simulations, 1), dtype=torch.bool)
+ return prior_mask_values((num_simulations, 2), dtype=torch.bool)
def _train(
self,
Mutant 250
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -313,7 +313,7 @@
"""
# Starting index for the training set (1 = discard round-0 samples).
- start_idx = int(discard_prior_samples and round_ > 0)
+ start_idx = int(discard_prior_samples and round_ >= 0)
num_total_examples = sum(len(theta) for theta in self._theta_bank[start_idx:])
# Select random neural net and validation splits from (theta, x) pairs.
Mutant 251
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -313,7 +313,7 @@
"""
# Starting index for the training set (1 = discard round-0 samples).
- start_idx = int(discard_prior_samples and round_ > 0)
+ start_idx = int(discard_prior_samples and round_ > 1)
num_total_examples = sum(len(theta) for theta in self._theta_bank[start_idx:])
# Select random neural net and validation splits from (theta, x) pairs.
Mutant 252
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -313,7 +313,7 @@
"""
# Starting index for the training set (1 = discard round-0 samples).
- start_idx = int(discard_prior_samples and round_ > 0)
+ start_idx = int(discard_prior_samples or round_ > 0)
num_total_examples = sum(len(theta) for theta in self._theta_bank[start_idx:])
# Select random neural net and validation splits from (theta, x) pairs.
Mutant 253
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -313,7 +313,7 @@
"""
# Starting index for the training set (1 = discard round-0 samples).
- start_idx = int(discard_prior_samples and round_ > 0)
+ start_idx = None
num_total_examples = sum(len(theta) for theta in self._theta_bank[start_idx:])
# Select random neural net and validation splits from (theta, x) pairs.
Mutant 262
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -336,7 +336,7 @@
train_loader = data.DataLoader(
dataset,
batch_size=min(training_batch_size, num_training_examples),
- drop_last=True,
+ drop_last=False,
sampler=SubsetRandomSampler(train_indices),
)
val_loader = data.DataLoader(
Mutant 264
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -343,7 +343,7 @@
dataset,
batch_size=min(training_batch_size, num_validation_examples),
shuffle=False,
- drop_last=True,
+ drop_last=False,
sampler=SubsetRandomSampler(val_indices),
)
Mutant 268
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -352,7 +352,7 @@
)
epoch, self._val_log_prob = 0, float("-Inf")
- while epoch <= max_num_epochs and not self._converged(epoch, stop_after_epochs):
+ while epoch < max_num_epochs and not self._converged(epoch, stop_after_epochs):
# Train for a single epoch.
self._posterior.net.train()
Mutant 274
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -370,7 +370,7 @@
)
)
batch_loss.backward()
- if clip_max_norm is not None:
+ if clip_max_norm is None:
clip_grad_norm_(
self._posterior.net.parameters(), max_norm=clip_max_norm,
)
Mutant 275
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -376,7 +376,7 @@
)
optimizer.step()
- epoch += 1
+ epoch = 1
# Calculate validation performance.
self._posterior.net.eval()
Mutant 276
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -376,7 +376,7 @@
)
optimizer.step()
- epoch += 1
+ epoch -= 1
# Calculate validation performance.
self._posterior.net.eval()
Mutant 277
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -376,7 +376,7 @@
)
optimizer.step()
- epoch += 1
+ epoch += 2
# Calculate validation performance.
self._posterior.net.eval()
Mutant 278
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -380,7 +380,7 @@
# Calculate validation performance.
self._posterior.net.eval()
- log_prob_sum = 0
+ log_prob_sum = 1
with torch.no_grad():
for batch in val_loader:
theta_batch, x_batch, masks_batch = (
Mutant 284
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -392,7 +392,7 @@
batch_log_prob = -self._loss(
round_, theta_batch, x_batch, masks_batch, calibration_kernel
)
- log_prob_sum += batch_log_prob.sum().item()
+ log_prob_sum = batch_log_prob.sum().item()
self._val_log_prob = log_prob_sum / num_validation_examples
Mutant 286
--- sbi/inference/snpe/snpe_base.py
+++ sbi/inference/snpe/snpe_base.py
@@ -394,7 +394,7 @@
)
log_prob_sum += batch_log_prob.sum().item()
- self._val_log_prob = log_prob_sum / num_validation_examples
+ self._val_log_prob = log_prob_sum * num_validation_examples
self._maybe_show_progress(self._show_progress_bars, epoch)