From ee85e20bcf3ab0063360b7e2604489b8e3d1a92a Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 16 Jul 2021 12:06:42 +0200 Subject: [PATCH 1/3] recover removed option --- n3fit/src/n3fit/model_trainer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/n3fit/src/n3fit/model_trainer.py b/n3fit/src/n3fit/model_trainer.py index 33896bbd91..55946d9f82 100644 --- a/n3fit/src/n3fit/model_trainer.py +++ b/n3fit/src/n3fit/model_trainer.py @@ -356,7 +356,7 @@ def _model_generation(self, pdf_models, partition, partition_idx): splitted_pdf = splitting_layer(full_pdf_per_replica) # If we are in a kfolding partition, select which datasets are out - if partition: + if partition and not partition.get("overfit", False): training_mask = [i[partition_idx] for i in self.training["folds"]] validation_mask = [i[partition_idx] for i in self.validation["folds"]] experimental_mask = [i[partition_idx] for i in self.experimental["folds"]] From c34b134007c8c4a7eb524c641b6197754a27dbd4 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 16 Jul 2021 15:07:45 +0200 Subject: [PATCH 2/3] updated doc, bugfix --- doc/sphinx/source/n3fit/hyperopt.rst | 3 ++- n3fit/src/n3fit/model_trainer.py | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/sphinx/source/n3fit/hyperopt.rst b/doc/sphinx/source/n3fit/hyperopt.rst index 3dcb47c12e..3cd79a076f 100644 --- a/doc/sphinx/source/n3fit/hyperopt.rst +++ b/doc/sphinx/source/n3fit/hyperopt.rst @@ -260,7 +260,8 @@ The partitions can be chosen by adding a ``kfold::partitions`` key to the runcar - data_5 The ``overfit`` flag, when applied to one of the partitions, introduces this partition in the -training data. This is useful for very broad scans where we want to find an architecture which is able to +fitted data, i.e., the training and validation are blind to that partition and will work normally. +This is useful for very broad scans where we want to find an architecture which is able to fit, without worrying about things like overlearning which might be a second-order problem. The ``weight`` (default 1.0) is multiplied with the loss function of the partition for which it is set. diff --git a/n3fit/src/n3fit/model_trainer.py b/n3fit/src/n3fit/model_trainer.py index 55946d9f82..85ee822146 100644 --- a/n3fit/src/n3fit/model_trainer.py +++ b/n3fit/src/n3fit/model_trainer.py @@ -356,12 +356,13 @@ def _model_generation(self, pdf_models, partition, partition_idx): splitted_pdf = splitting_layer(full_pdf_per_replica) # If we are in a kfolding partition, select which datasets are out - if partition and not partition.get("overfit", False): - training_mask = [i[partition_idx] for i in self.training["folds"]] - validation_mask = [i[partition_idx] for i in self.validation["folds"]] + training_mask = validation_mask = experimental_mask = [None] + if partition: + if partition.get("overfit", False): + # If overfitting, don't apply folding masks to the training/validation + training_mask = [i[partition_idx] for i in self.training["folds"]] + validation_mask = [i[partition_idx] for i in self.validation["folds"]] experimental_mask = [i[partition_idx] for i in self.experimental["folds"]] - else: - training_mask = validation_mask = experimental_mask = [None] # Training and validation leave out the kofld dataset # experiment leaves out the negation From caf959111b6b1264a14fe09f9bdfe10deb02c7b0 Mon Sep 17 00:00:00 2001 From: "Juan M. Cruz-Martinez" Date: Fri, 16 Jul 2021 15:45:09 +0200 Subject: [PATCH 3/3] Update doc/sphinx/source/n3fit/hyperopt.rst Co-authored-by: Roy Stegeman --- doc/sphinx/source/n3fit/hyperopt.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sphinx/source/n3fit/hyperopt.rst b/doc/sphinx/source/n3fit/hyperopt.rst index 3cd79a076f..b4307cf101 100644 --- a/doc/sphinx/source/n3fit/hyperopt.rst +++ b/doc/sphinx/source/n3fit/hyperopt.rst @@ -260,7 +260,7 @@ The partitions can be chosen by adding a ``kfold::partitions`` key to the runcar - data_5 The ``overfit`` flag, when applied to one of the partitions, introduces this partition in the -fitted data, i.e., the training and validation are blind to that partition and will work normally. +fitted data, i.e., the training and validation always include that partition and will work normally. This is useful for very broad scans where we want to find an architecture which is able to fit, without worrying about things like overlearning which might be a second-order problem.