-
Notifications
You must be signed in to change notification settings - Fork 1
/
argParse.py
94 lines (68 loc) · 2.33 KB
/
argParse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import argparse
import numpy as np
def argParser_block():
"""! Argument parser
This function reads input argument from command line and returns corresponding program options.
Returns
-------
data_name : dataset name
num_blk : number of blocks used to separate the whole sample
num_epoch : number of epoch to run
"""
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-blk", required=False, help="number of blocks")
ap.add_argument("-bat", required=False, help="batch size at each iteration")
ap.add_argument("-d", required=False, help="data name")
ap.add_argument("-ep", required=False, help="number of epoch to run")
# read arguments
args = ap.parse_args()
if args.blk:
blk = args.blk
else:
blk = 32
if args.bat:
print("WARNING: This script does not support -bat parameter. will ignore this parameter.")
if args.d:
data_name = args.d
else:
print("WARNING: data name not selected. will run default data if exists.")
data_name = None
if args.ep:
epoch = args.ep
else:
epoch = 300
return blk, data_name, epoch
def argParser_batch():
"""! Argument parser
This function reads input argument from command line and returns corresponding program options.
Returns
-------
data_name : dataset name
num_epoch : number of epoch to run
batch_size : batch size
"""
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-blk", required=False, help="number of blocks")
ap.add_argument("-bat", required=False, help="batch size at each iteration")
ap.add_argument("-d", required=False, help="data name")
ap.add_argument("-ep", required=False, help="number of epoch to run")
# read arguments
args = ap.parse_args()
if args.blk:
print("WARNING: This script does not support -blk parameter. will ignore this parameter.")
if args.bat:
bat = args.bat
else:
bat = 1
if args.d:
data_name = args.d
else:
print("WARNING: data name not selected. will run default data if exists")
data_name = None
if args.ep:
epoch = args.ep
else:
epoch = 3
return bat, data_name, epoch