| 29 | amp = None |
| 30 | |
| 31 | def parse_option(): |
| 32 | parser = argparse.ArgumentParser('RepOpt-VGG training script built on the codebase of Swin Transformer', add_help=False) |
| 33 | parser.add_argument( |
| 34 | "--opts", |
| 35 | help="Modify config options by adding 'KEY VALUE' pairs. ", |
| 36 | default=None, |
| 37 | nargs='+', |
| 38 | ) |
| 39 | |
| 40 | # easy config modification |
| 41 | parser.add_argument('--arch', default=None, type=str, help='arch name') |
| 42 | parser.add_argument('--batch-size', default=128, type=int, help="batch size for single GPU") |
| 43 | parser.add_argument('--data-path', default='/your/path/to/dataset', type=str, help='path to dataset') |
| 44 | parser.add_argument('--scales-path', default=None, type=str, help='path to the trained Hyper-Search model') |
| 45 | parser.add_argument('--zip', action='store_true', help='use zipped dataset instead of folder dataset') |
| 46 | parser.add_argument('--cache-mode', type=str, default='part', choices=['no', 'full', 'part'], |
| 47 | help='no: no cache, ' |
| 48 | 'full: cache all data, ' |
| 49 | 'part: sharding the dataset into nonoverlapping pieces and only cache one piece') |
| 50 | parser.add_argument('--resume', help='resume from checkpoint') |
| 51 | parser.add_argument('--accumulation-steps', type=int, help="gradient accumulation steps") |
| 52 | parser.add_argument('--use-checkpoint', action='store_true', |
| 53 | help="whether to use gradient checkpointing to save memory") |
| 54 | parser.add_argument('--amp-opt-level', type=str, default='O0', choices=['O0', 'O1', 'O2'], #TODO Note: use amp if you have it |
| 55 | help='mixed precision opt level, if O0, no amp is used') |
| 56 | parser.add_argument('--output', default='/your/path/to/save/dir', type=str, metavar='PATH', |
| 57 | help='root of output folder, the full path is <output>/<model_name>/<tag> (default: output)') |
| 58 | parser.add_argument('--tag', help='tag of experiment') |
| 59 | parser.add_argument('--eval', action='store_true', help='Perform evaluation only') |
| 60 | parser.add_argument('--throughput', action='store_true', help='Test throughput only') |
| 61 | |
| 62 | # distributed training |
| 63 | parser.add_argument("--local_rank", type=int, default=0, help='local rank for DistributedDataParallel') |
| 64 | |
| 65 | args, unparsed = parser.parse_known_args() |
| 66 | |
| 67 | config = get_config(args) |
| 68 | |
| 69 | return args, config |
| 70 | |
| 71 | |
| 72 | |