-
Notifications
You must be signed in to change notification settings - Fork 0
/
training_args.py
executable file
·177 lines (153 loc) · 7.55 KB
/
training_args.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
"""
Copyright (c) 2017, Jun-Yan Zhu and Taesung Park
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------- LICENSE FOR pix2pix --------------------------------
BSD License
For pix2pix software
Copyright (c) 2016, Phillip Isola and Jun-Yan Zhu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
----------------------------- LICENSE FOR DCGAN --------------------------------
BSD License
For dcgan.torch software
Copyright (c) 2015, Facebook, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name Facebook nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import argparse
from base_args import BaseArgs
from mutants.utils import find_all_mutation_operators
from rl_zoo3.utils import StoreDict
from training.training_type import TrainingType
class TrainingArgs(BaseArgs):
"""
This class includes custom options.
It also includes shared options defined in BaseOptions.
"""
def initialize(self, parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
parser = BaseArgs.initialize(self, parser=parser)
parser.add_argument(
"--register-env",
action="store_true",
default=False,
help="Register env with its args and override existing one",
)
parser.add_argument(
"--log-success",
action="store_true",
default=False,
help="Log success in the monitor file during training",
)
parser.add_argument(
"--test-generation",
action="store_true",
default=False,
help="Enable test generation (enables logging of initial configurations during training)",
)
parser.add_argument(
"--eval-env",
action="store_true",
default=False,
help='Enable creation of evaluation environment. The difference with "--eval-freq" is that '
"in this case the frequency is decided automatically, i.e., 10% of the total "
"training timesteps.",
)
parser.add_argument(
"--custom-env-kwargs",
type=str,
nargs="+",
action=StoreDict,
help="Custom keyword argument to pass to the env constructor",
default=None,
)
parser.add_argument(
"--wrapper-kwargs",
type=str,
nargs="*",
action=StoreDict,
help="Wrapper keyword arguments",
default=None,
)
parser.add_argument(
"--num-runs", type=int, help="Number of runs for the agent", default=1
)
parser.add_argument(
"--num-cpus",
type=int,
help="Number of cpus to be used for parallelization (default = -1, i.e., the number of logical cores in the current machine)",
default=-1,
)
parser.add_argument(
"--training-type",
type=str,
choices=[training_type.name for training_type in TrainingType],
help=f"Type of training, i.e., {[training_type.name for training_type in TrainingType]}",
default=TrainingType.original.name,
)
parser.add_argument(
"--mutant-name",
type=str,
choices=find_all_mutation_operators(),
help="Mutation operator name (see package 'mutants'; each mutant is named <name>_mutant.py). "
"This flag is only considered when 'training_type' == 'mutant'",
default=None,
)
parser.add_argument(
"--search-budget",
type=int,
help="Search budget for the mutation in terms of number of mutations",
default=1,
)
parser.add_argument(
"--search-iteration",
type=int,
help="It is meant to parallelize "
"the execution of different mutants on multiple machines. It should be < search-budget (starts from 0)",
default=-1,
)
parser.add_argument(
"--run-num",
type=int,
help="Only works with parallelization disabled. It is meant to parallelize "
"the execution of different runs on multiple machines. It should be < num_runs (starts from 0)",
default=-1,
)
parser.add_argument(
"--mock",
action="store_true",
help="Mock the execution (only works parallelization disabled)",
default=False,
)
parser.add_argument(
"--parallelize",
action="store_true",
help="Parallelize training runs",
default=False,
)
return parser