diff --git a/n3fit/runcards/Basic_runcard.yml b/n3fit/runcards/Basic_runcard.yml index 81e1b9cf21cdc6ef0a5a8d31691cff120da62848..6ee25db7367784cef0c585d1c9d73458d0fd4e08 100644 --- a/n3fit/runcards/Basic_runcard.yml +++ b/n3fit/runcards/Basic_runcard.yml @@ -66,6 +66,7 @@ fitting: positivity: multiplier: 1.05 # When any of the multiplier and/or the initial is not set initial: # the poslambda will be used instead to compute these values per dataset + threshold: 1e-5 stopping_patience: 0.30 # percentage of the number of epochs layer_type: 'dense' dropout: 0.0 diff --git a/n3fit/src/n3fit/ModelTrainer.py b/n3fit/src/n3fit/ModelTrainer.py index 1b74946716edd0b481af38163208d38009f6668e..53dbf57e638d0cf87cbe54e435115a93182576fd 100644 --- a/n3fit/src/n3fit/ModelTrainer.py +++ b/n3fit/src/n3fit/ModelTrainer.py @@ -804,6 +804,7 @@ class ModelTrainer: integrability_dict.get("initial"), epochs, ) + threshold_pos = positivity_dict.get("threshold", 1e-6) # Initialize the chi2 dictionaries l_train = [] @@ -864,6 +865,7 @@ class ModelTrainer: total_epochs=epochs, stopping_patience=stopping_epochs, save_weights_each=self.save_weights_each, + threshold_positivity=threshold_pos ) # Compile each of the models with the right parameters diff --git a/n3fit/src/n3fit/checks.py b/n3fit/src/n3fit/checks.py index 61294e1403ed18c4409ff5ccb01723911fc3fe6d..df871a9e2aec7140b4a5ca94f2e4087d57ad4068 100644 --- a/n3fit/src/n3fit/checks.py +++ b/n3fit/src/n3fit/checks.py @@ -94,11 +94,15 @@ def check_dropout(parameters): if dropout is not None and not 0.0 <= dropout <= 1.0: raise CheckError(f"Dropout must be between 0 and 1, got: {dropout}") + def check_tensorboard(tensorboard): if tensorboard is not None: weight_freq = tensorboard.get("weight_freq", 0) if weight_freq < 0: - raise CheckError(f"The frequency at which weights are saved must be greater than 0, received {weight_freq}") + raise CheckError( + f"The frequency at which weights are saved must be greater than 0, received {weight_freq}" + ) + @make_argcheck def wrapper_check_NN(fitting): @@ -163,6 +167,14 @@ def check_hyperopt_positivity(positivity_dict): ) if max_ini <= min_ini: raise CheckError("The minimum initial value cannot be greater than the maximum") + threshold = positivity_dict.get("threshold") + if threshold is not None: + try: + 4.0 < threshold + except TypeError as e: + raise CheckError( + f"The positivity::threshold must be a number, received: {threhsold}" + ) from e def check_kfold_options(kfold):