Installation & Usage ¶
Installation ¶
The software is now available on the pip Python package manager and can be installed straightforwardly by typing the following command:
pip install hpo-uq
Dependencies ¶
The HYPPO package relies on several external Python packages in order to work, some of which may only be needed if the operation that utilizes the package is requested. Below we list all the dependencies along with a short description of the package and the condition for when the library is loaded:
Package Name |
Description |
When is it used? |
---|---|---|
|
Evolutionary computation framework |
Only for Surrogate modeling |
|
Visualization library |
Always |
|
Mathematical and Numerical analysis |
Always |
|
Data Manipulation |
Only for CSV data extraction |
|
Pickle module compatible for Python 3.8.3 |
When doing HPO |
|
Interactive visualization library |
Only for Surrogate modeling |
|
YAML parser and emitter |
Always |
|
Sensitivity Analysis Library |
Only for Sensitivity Analysis |
|
Mathematical and Numerical analysis |
Always |
|
Data preprocessing and normalization |
Always |
|
Machine Learning library |
Only if training done in Tensorflow |
|
Machine Learning library |
Only if training done in PyTorch |
Executable Script ¶
The executable python routine shown further below is the main script that executes the hyperparameter optimization. It is located in a
bin
folder which is included in the system PATH so that the user can easily call the script either from the terminal command line or through a SLURM script. The only two required input for the script are, in order, the name of the operation that should be executed and the path to the configuration file. The following four operations can be executed through the script:
-
sampling
: Generate the hyperparameter sets to be used in the evaluation step. -
slurm
: Create SLURM script (script.sh
) to execute the requested operations on a multi-processing setup. -
evaluation
: Execute the training on initialized hyperparameter sets which will then be used for surrogate modeling. -
surrogate
: Perform surrogate modeling using the evaluated hyperparameter sets.
#!/usr/bin/env python
# System
import argparse
import yaml
# Local
import hyppo
def parse_args():
"""
Parse command line arguments.
"""
parser = argparse.ArgumentParser('hyppo',description="A novel UQ-informed surrogate-based hyperparameter optimization tool.",
epilog="Copyright (c) 2022, The Regents of the University of California. All rights reserved.")
add_arg = parser.add_argument
add_arg('operation', choices=['sampling','sbatch','evaluation','surrogate'],
help='Operation to be executed')
add_arg('config_file',
help='Input configuration file')
add_arg('-d','--debug', metavar='', type=int, default=0,
help='Show model summary, for debugging purposes')
add_arg('--no-submit', action='store_true',
help='For sbatch operation, only create batch, do no submit job')
add_arg('-v', '--verbose', action='store_true', help='Enable verbose logging')
return parser.parse_args()
def main():
print(" ____________________________________ ")
print(" | _ | ")
print(" | | | https://hpo-uq.gitlab.io/ | ")
print(" | | |__ _ _ _ __ _ __ ___ | ")
print(" | | '_ \ \ / | '_ \| '_ \ / _ \ | ")
print(" | | | | \ ' /| |_) | |_) | (_) | | ")
print(" | |_| |_|/ / | .__/| .__/ \___/ | ")
print(" | / / | | | | | ")
print(" | /_/ |_| |_| | ")
print(" |____________________________________|\n")
# Extract user arguments
args = parse_args()
# Load configuration file
config = hyppo.load_config(**vars(args))
# Execute relevant action
eval('hyppo.'+args.operation)(config)
if __name__ == '__main__':
main()