Download main.py from FelixOtt/gnss_class_incremental_learning: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/datasets/FelixOtt/gnss_class_incremental_learning/resolve/main/main.py
- Command line
-
hf download hf://datasets/FelixOtt/gnss_class_incremental_learning/main.py
-
curl -L -o main.py https://huggingface.co/datasets/FelixOtt/gnss_class_incremental_learning/resolve/main/main.py
1.8 kB
| import json | |
| import argparse | |
| from trainer import train | |
| import json | |
| def string_to_list(args): | |
| """ | |
| Convert a JSON string to a Python list. | |
| Args: | |
| args (str): JSON string representing a list. | |
| Returns: | |
| list: Parsed list from the JSON string. | |
| """ | |
| return json.loads(args) | |
| def main(): | |
| """ | |
| Function to set up the training process. | |
| Parses command line arguments, loads configuration from a JSON file, and starts the training. | |
| """ | |
| # Parse command-line arguments | |
| args = setup_parser().parse_args() | |
| param = load_json(args.config) | |
| args = vars(args) | |
| args.update(param) | |
| train(args) | |
| def load_json(settings_path): | |
| """ | |
| Load parameters from a JSON file. | |
| Args: | |
| settings_path (str): Path to the JSON configuration file. | |
| Returns: | |
| dict: Configuration parameters loaded from the JSON file. | |
| """ | |
| with open(settings_path) as data_file: | |
| param = json.load(data_file) | |
| return param | |
| def setup_parser(): | |
| parser = argparse.ArgumentParser(description='Reproduce of multiple continual learning algorthms.') | |
| parser.add_argument('--config', type=str, default='./exps/finetune.json', help='Json file of settings.') | |
| parser.add_argument('--dataset', default="gnss", help="Kind of dataset", type=str) | |
| parser.add_argument('--summary_file', type=str, default='run_new',help='path for the tensorboard experiment') | |
| parser.add_argument('--layers', help='delimited list input', type=string_to_list) | |
| parser.add_argument('--type', default="normal", help='Type of memo models (normal or avg)', type=str) | |
| parser.add_argument('--convnet_type', default="memo_resnet32", help="Kind of resnet", type=str) | |
| return parser | |
| if __name__ == '__main__': | |
| main() | |