MCPcopy Create free account
hub / github.com/SwinTransformer/Transformer-SSL / parse_option

Function parse_option

moby_linear.py:37–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35
36
37def parse_option():
38 parser = argparse.ArgumentParser('Swin Transformer training and evaluation script', add_help=False)
39 parser.add_argument('--cfg', type=str, required=True, metavar="FILE", help='path to config file', )
40 parser.add_argument(
41 "--opts",
42 help="Modify config options by adding 'KEY VALUE' pairs. ",
43 default=None,
44 nargs='+',
45 )
46
47 # easy config modification
48 parser.add_argument('--batch-size', type=int, help="batch size for single GPU")
49 parser.add_argument('--data-path', type=str, help='path to dataset')
50 parser.add_argument('--zip', action='store_true', help='use zipped dataset instead of folder dataset')
51 parser.add_argument('--cache-mode', type=str, default='part', choices=['no', 'full', 'part'],
52 help='no: no cache, '
53 'full: cache all data, '
54 'part: sharding the dataset into nonoverlapping pieces and only cache one piece')
55 parser.add_argument('--resume', help='resume from checkpoint')
56 parser.add_argument('--accumulation-steps', type=int, help="gradient accumulation steps")
57 parser.add_argument('--use-checkpoint', action='store_true',
58 help="whether to use gradient checkpointing to save memory")
59 parser.add_argument('--amp-opt-level', type=str, default='O1', choices=['O0', 'O1', 'O2'],
60 help='mixed precision opt level, if O0, no amp is used')
61 parser.add_argument('--output', default='output', type=str, metavar='PATH',
62 help='root of output folder, the full path is <output>/<model_name>/<tag> (default: output)')
63 parser.add_argument('--tag', help='tag of experiment')
64 parser.add_argument('--eval', action='store_true', help='Perform evaluation only')
65 parser.add_argument('--throughput', action='store_true', help='Test throughput only')
66
67 # distributed training
68 parser.add_argument("--local_rank", type=int, required=True, help='local rank for DistributedDataParallel')
69
70 # dev: linear eval settings
71 parser.add_argument('--lr', type=float, default=1.0, help='the base lr for linear evaluation')
72 parser.add_argument('--drop-path-rate', type=float, default=0.2, help='the drop path rate used in linear evaluation')
73
74 args, unparsed = parser.parse_known_args()
75
76 config = get_config(args)
77
78 config.defrost()
79 # base
80 config.LINEAR_EVAL.PRETRAINED = os.path.join(config.OUTPUT, 'checkpoint.pth')
81 config.OUTPUT = os.path.join(config.OUTPUT, 'linear')
82 # model
83 config.MODEL.TYPE = 'linear'
84 config.MODEL.DROP_PATH_RATE = args.drop_path_rate
85 # aug
86 config.AUG.SSL_AUG = False
87 config.AUG.SSL_LINEAR_AUG = True
88 config.AUG.MIXUP = 0.0
89 config.AUG.CUTMIX = 0.0
90 config.AUG.CUTMIX_MINMAX = None
91 # train
92 config.TRAIN.EPOCHS = 100
93 config.TRAIN.WARMUP_EPOCHS = 5
94 # sched

Callers 1

moby_linear.pyFile · 0.70

Calls 1

get_configFunction · 0.90

Tested by

no test coverage detected