From 55838d24db6a66c9fbdb08980c19776bc282072b Mon Sep 17 00:00:00 2001 From: Eli Fajardo Date: Mon, 10 Apr 2023 19:58:50 +0000 Subject: [PATCH 1/4] fix string formatting in debug lines --- morpheus/models/dfencoder/autoencoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/morpheus/models/dfencoder/autoencoder.py b/morpheus/models/dfencoder/autoencoder.py index 566c5caf2b..253e80bcb8 100644 --- a/morpheus/models/dfencoder/autoencoder.py +++ b/morpheus/models/dfencoder/autoencoder.py @@ -905,11 +905,11 @@ def _fit_centralized(self, df, epochs=1, val=None, run_validation=False, use_val # Early stopping current_net_loss = net_loss - LOG.debug('The Current Net Loss:', current_net_loss) + LOG.debug('The Current Net Loss: {}'.format(current_net_loss)) if current_net_loss > last_loss: count_es += 1 - LOG.debug('Early stop count:', count_es) + LOG.debug('Early stop count: {}'.format(count_es)) if count_es >= self.patience: LOG.debug('Early stopping: early stop count({}) >= patience({})'.format( From ab01bfc34e6f23805f407cb3db544ac315729e77 Mon Sep 17 00:00:00 2001 From: Eli Fajardo Date: Mon, 10 Apr 2023 20:00:01 +0000 Subject: [PATCH 2/4] use eval_batch_size for loss stats --- morpheus/models/dfencoder/autoencoder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/morpheus/models/dfencoder/autoencoder.py b/morpheus/models/dfencoder/autoencoder.py index 253e80bcb8..236c4404fa 100644 --- a/morpheus/models/dfencoder/autoencoder.py +++ b/morpheus/models/dfencoder/autoencoder.py @@ -1617,15 +1617,15 @@ def get_anomaly_score_losses(self, df): """ self.eval() - n_batches = len(df) // self.batch_size - if len(df) % self.batch_size > 0: + n_batches = len(df) // self.eval_batch_size + if len(df) % self.eval_batch_size > 0: n_batches += 1 mse_loss_slices, bce_loss_slices, cce_loss_slices = [], [], [] with torch.no_grad(): for i in range(n_batches): - start = i * self.batch_size - stop = (i + 1) * self.batch_size + start = i * self.eval_batch_size + stop = (i + 1) * self.eval_batch_size df_slice = df.iloc[start:stop] data_slice = self.prepare_df(df_slice) From c64e4785c32533c968e810d295ae3546c2847cf3 Mon Sep 17 00:00:00 2001 From: Eli Fajardo Date: Fri, 14 Apr 2023 19:34:26 +0000 Subject: [PATCH 3/4] use lazy formatting for logger messages --- morpheus/models/dfencoder/autoencoder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/morpheus/models/dfencoder/autoencoder.py b/morpheus/models/dfencoder/autoencoder.py index 236c4404fa..a8abb68816 100644 --- a/morpheus/models/dfencoder/autoencoder.py +++ b/morpheus/models/dfencoder/autoencoder.py @@ -905,15 +905,15 @@ def _fit_centralized(self, df, epochs=1, val=None, run_validation=False, use_val # Early stopping current_net_loss = net_loss - LOG.debug('The Current Net Loss: {}'.format(current_net_loss)) + LOG.debug('The Current Net Loss: %s', current_net_loss) if current_net_loss > last_loss: count_es += 1 - LOG.debug('Early stop count: {}'.format(count_es)) + LOG.debug('Early stop count: %s', count_es) if count_es >= self.patience: - LOG.debug('Early stopping: early stop count({}) >= patience({})'.format( - count_es, self.patience)) + LOG.debug('Early stopping: early stop count(%s) >= patience(%s)', + count_es, self.patience) break else: From f96b9ddad26c87fcc2fe70b4151543a287bf65b2 Mon Sep 17 00:00:00 2001 From: Eli Fajardo Date: Fri, 14 Apr 2023 19:35:40 +0000 Subject: [PATCH 4/4] style fix --- morpheus/models/dfencoder/autoencoder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/morpheus/models/dfencoder/autoencoder.py b/morpheus/models/dfencoder/autoencoder.py index a8abb68816..f7590d9b8d 100644 --- a/morpheus/models/dfencoder/autoencoder.py +++ b/morpheus/models/dfencoder/autoencoder.py @@ -912,8 +912,7 @@ def _fit_centralized(self, df, epochs=1, val=None, run_validation=False, use_val LOG.debug('Early stop count: %s', count_es) if count_es >= self.patience: - LOG.debug('Early stopping: early stop count(%s) >= patience(%s)', - count_es, self.patience) + LOG.debug('Early stopping: early stop count(%s) >= patience(%s)', count_es, self.patience) break else: