diff --git a/hydragnn/postprocess/postprocess.py b/hydragnn/postprocess/postprocess.py index 72e367030..c28dd39d8 100644 --- a/hydragnn/postprocess/postprocess.py +++ b/hydragnn/postprocess/postprocess.py @@ -12,11 +12,10 @@ def output_denormalize(y_minmax, true_values, predicted_values): for ihead in range(len(y_minmax)): - for isample in range(len(predicted_values[0])): - for iatom in range(len(predicted_values[ihead][0])): - ymin = y_minmax[ihead][0] - ymax = y_minmax[ihead][1] - + ymin = y_minmax[ihead][0] + ymax = y_minmax[ihead][1] + for isample in range(len(predicted_values[ihead])): + for iatom in range(len(predicted_values[ihead][isample])): predicted_values[ihead][isample][iatom] = ( predicted_values[ihead][isample][iatom] * (ymax - ymin) + ymin ) diff --git a/hydragnn/run_prediction.py b/hydragnn/run_prediction.py index e7da7aace..b32e35fb5 100755 --- a/hydragnn/run_prediction.py +++ b/hydragnn/run_prediction.py @@ -22,6 +22,7 @@ from hydragnn.utils.config_utils import ( update_config_NN_outputs, get_model_output_name_config, + normalize_output_config, ) from hydragnn.utils.model import calculate_PNA_degree from hydragnn.models.create import create_model_config @@ -62,6 +63,8 @@ def _(config: dict): ) config = update_config_NN_outputs(config, graph_size_variable) + config = normalize_output_config(config) + config["NeuralNetwork"]["Architecture"]["input_dim"] = len( config["NeuralNetwork"]["Variables_of_interest"]["input_node_features"] ) diff --git a/hydragnn/utils/config_utils.py b/hydragnn/utils/config_utils.py index 01497a7cb..5a0035135 100644 --- a/hydragnn/utils/config_utils.py +++ b/hydragnn/utils/config_utils.py @@ -46,11 +46,14 @@ def update_config_NN_outputs(config, graph_size_variable): def normalize_output_config(config): var_config = config["NeuralNetwork"]["Variables_of_interest"] if "denormalize_output" in var_config and var_config["denormalize_output"]: - if "total" in config["Dataset"]["path"].keys(): - dataset_path = f"{os.environ['SERIALIZED_DATA_PATH']}/serialized_dataset/{config['Dataset']['name']}.pkl" + ###loading min/max values from input data file. Only one path is needed + if list(config["Dataset"]["path"].values())[0].endswith(".pkl"): + dataset_path = list(config["Dataset"]["path"].values())[0] else: - ###used for min/max values loading below - dataset_path = f"{os.environ['SERIALIZED_DATA_PATH']}/serialized_dataset/{config['Dataset']['name']}_train.pkl" + if "total" in config["Dataset"]["path"].keys(): + dataset_path = f"{os.environ['SERIALIZED_DATA_PATH']}/serialized_dataset/{config['Dataset']['name']}.pkl" + else: + dataset_path = f"{os.environ['SERIALIZED_DATA_PATH']}/serialized_dataset/{config['Dataset']['name']}_train.pkl" var_config = update_config_minmax(dataset_path, var_config) else: var_config["denormalize_output"] = False