|
a |
|
b/config.py |
|
|
1 |
import configargparse |
|
|
2 |
|
|
|
3 |
def list_of_list_of_floats(x): |
|
|
4 |
temp = x.replace('[', '').replace(']', '').split(',') |
|
|
5 |
temp2 = [float(temp_e) for temp_e in temp] |
|
|
6 |
|
|
|
7 |
return temp2 |
|
|
8 |
|
|
|
9 |
def list_of_string_names(x): |
|
|
10 |
|
|
|
11 |
return x |
|
|
12 |
|
|
|
13 |
def list_of_tuples_of_strings(x): |
|
|
14 |
|
|
|
15 |
temp = x.replace('[', '').replace(']', '').split(';') |
|
|
16 |
|
|
|
17 |
return temp |
|
|
18 |
|
|
|
19 |
def boolean_string(s): |
|
|
20 |
if s not in {'False', 'True'}: |
|
|
21 |
raise ValueError('Not a valid boolean string') |
|
|
22 |
return s == 'True' |
|
|
23 |
|
|
|
24 |
def config_parser(): |
|
|
25 |
parser = configargparse.ArgumentParser() |
|
|
26 |
|
|
|
27 |
parser.add_argument("--config", is_config_file=True, help="config file path") |
|
|
28 |
|
|
|
29 |
parser.add_argument('--model', |
|
|
30 |
type=str, |
|
|
31 |
default="rnn", |
|
|
32 |
help='rnn, gru') |
|
|
33 |
|
|
|
34 |
parser.add_argument('--gamma', |
|
|
35 |
type=float, |
|
|
36 |
default=0.99, |
|
|
37 |
help='discount factor for reward (default: 0.99)') |
|
|
38 |
|
|
|
39 |
parser.add_argument('--tau', |
|
|
40 |
type=float, |
|
|
41 |
default=0.005, |
|
|
42 |
help='target smoothing coefficient(τ) (default: 0.005)') |
|
|
43 |
|
|
|
44 |
parser.add_argument('--lr', |
|
|
45 |
type=float, |
|
|
46 |
default=0.0003, |
|
|
47 |
help='learning rate (default: 0.001)') |
|
|
48 |
|
|
|
49 |
parser.add_argument('--alpha', |
|
|
50 |
type=float, |
|
|
51 |
default=0.2, |
|
|
52 |
help='Temperature parameter α determines the relative importance of the entropy\ |
|
|
53 |
term against the reward (default: 0.2)') |
|
|
54 |
|
|
|
55 |
parser.add_argument('--automatic_entropy_tuning', |
|
|
56 |
type=boolean_string, |
|
|
57 |
default=True, |
|
|
58 |
help='Automaically adjust α (default: False)') |
|
|
59 |
|
|
|
60 |
parser.add_argument('--seed', |
|
|
61 |
type=int, |
|
|
62 |
default=123456, |
|
|
63 |
help='random seed (default: 123456)') |
|
|
64 |
|
|
|
65 |
parser.add_argument('--policy_batch_size', |
|
|
66 |
type=int, |
|
|
67 |
default=8, |
|
|
68 |
help='batch size (default: 8)') |
|
|
69 |
|
|
|
70 |
parser.add_argument('--hidden_size', |
|
|
71 |
type=int, |
|
|
72 |
default=256, |
|
|
73 |
help='hidden size (default: 1000)') |
|
|
74 |
|
|
|
75 |
parser.add_argument('--policy_replay_size', |
|
|
76 |
type=int, |
|
|
77 |
default=50000, |
|
|
78 |
help='size of replay buffer (default: 2800)') |
|
|
79 |
|
|
|
80 |
parser.add_argument('--multi_policy_loss', |
|
|
81 |
type=boolean_string, |
|
|
82 |
default=False, |
|
|
83 |
help='use additional policy losses') |
|
|
84 |
|
|
|
85 |
parser.add_argument('--batch_iters', |
|
|
86 |
type=int, |
|
|
87 |
default=1, |
|
|
88 |
help='iterations to apply update') |
|
|
89 |
|
|
|
90 |
parser.add_argument('--cuda', |
|
|
91 |
action="store_true", |
|
|
92 |
help='run on CUDA (default: False)') |
|
|
93 |
|
|
|
94 |
parser.add_argument('--visualize', |
|
|
95 |
type=boolean_string, |
|
|
96 |
default=False, |
|
|
97 |
help='visualize monkey/mouse') |
|
|
98 |
|
|
|
99 |
parser.add_argument('--root_dir', |
|
|
100 |
type=str, |
|
|
101 |
default='', |
|
|
102 |
help='specify you root directory') |
|
|
103 |
|
|
|
104 |
parser.add_argument('--checkpoint_file', |
|
|
105 |
type=str, |
|
|
106 |
default='agent_networks', |
|
|
107 |
help='specify the name of the file in which you would like to save model weights/training params (do not add extension). Also saves statistics file in root of project folder with same name') |
|
|
108 |
|
|
|
109 |
parser.add_argument('--checkpoint_folder', |
|
|
110 |
type=str, |
|
|
111 |
default= 'checkpoint', |
|
|
112 |
help='specify the name of the folder in which you would like to save the checkpoint file') |
|
|
113 |
|
|
|
114 |
parser.add_argument('--statistics_folder', |
|
|
115 |
type=str, |
|
|
116 |
default= 'training_statistics', |
|
|
117 |
help='specify the name of the folder in which you would like to save the training statistics') |
|
|
118 |
|
|
|
119 |
parser.add_argument('--total_episodes', |
|
|
120 |
type=int, |
|
|
121 |
default=5000000, |
|
|
122 |
help='total number of episodes') |
|
|
123 |
|
|
|
124 |
parser.add_argument('--save_iter', |
|
|
125 |
type=int, |
|
|
126 |
default=100, |
|
|
127 |
help='number of episodes until checkpoint is saved') |
|
|
128 |
|
|
|
129 |
parser.add_argument('--mode', |
|
|
130 |
type=str, |
|
|
131 |
default="train", |
|
|
132 |
help='select whether to train or test a model (train, test, SFE, sensory_pert, neural_pert, musculo_properties)') |
|
|
133 |
|
|
|
134 |
|
|
|
135 |
parser.add_argument('--verbose_training', |
|
|
136 |
type=boolean_string, |
|
|
137 |
default=False, |
|
|
138 |
help='Print statistics during training') |
|
|
139 |
|
|
|
140 |
parser.add_argument('--load_saved_nets_for_training', |
|
|
141 |
type=boolean_string, |
|
|
142 |
default=False, |
|
|
143 |
help='select whether to train or test a model (train, test)') |
|
|
144 |
|
|
|
145 |
parser.add_argument('--musculoskeletal_model_path', |
|
|
146 |
type=str, |
|
|
147 |
default='musculoskeletal_model/musculoskeletal_model.xml', |
|
|
148 |
help='path of musculoskeletal model') |
|
|
149 |
|
|
|
150 |
parser.add_argument('--initial_pose_path', |
|
|
151 |
type=str, |
|
|
152 |
default='initial_pose', |
|
|
153 |
help='path of musculoskeletal model') |
|
|
154 |
|
|
|
155 |
parser.add_argument('--kinematics_path', |
|
|
156 |
type=str, |
|
|
157 |
default='kinematics_data', |
|
|
158 |
help='path to kinematics data') |
|
|
159 |
|
|
|
160 |
parser.add_argument('--nusim_data_path', |
|
|
161 |
type=str, |
|
|
162 |
default='nusim_neural_data', |
|
|
163 |
help='path to nusim neural data for training and testing') |
|
|
164 |
|
|
|
165 |
parser.add_argument('--stimulus_data_path', |
|
|
166 |
type=str, |
|
|
167 |
default='stimulus_data', |
|
|
168 |
help='path to experimental stimulus data for training and testing') |
|
|
169 |
|
|
|
170 |
parser.add_argument('--test_data_filename', |
|
|
171 |
type=str, |
|
|
172 |
default='test_data', |
|
|
173 |
help='filename for saving the testing data') |
|
|
174 |
|
|
|
175 |
parser.add_argument('--condition_selection_strategy', |
|
|
176 |
type=str, |
|
|
177 |
default='reward', |
|
|
178 |
help='whether to select the next condition based on the corresponding average reward accumulated so far') |
|
|
179 |
|
|
|
180 |
parser.add_argument('--sim_dt', |
|
|
181 |
type=int, |
|
|
182 |
default=0, |
|
|
183 |
help='The timestep for the simulation: Keep 0 for default simulation timestep') |
|
|
184 |
|
|
|
185 |
parser.add_argument('--frame_repeat', |
|
|
186 |
type=int, |
|
|
187 |
default=5, |
|
|
188 |
help='The frames/timepoints for which the same action should be repeated during training of the agent') |
|
|
189 |
|
|
|
190 |
parser.add_argument('--n_fixedsteps', |
|
|
191 |
type=int, |
|
|
192 |
default=25, |
|
|
193 |
help='The target will remain at kinematic[timestep=0] for n_fixedsteps') |
|
|
194 |
|
|
|
195 |
parser.add_argument('--timestep_limit', |
|
|
196 |
type=int, |
|
|
197 |
default=1000, |
|
|
198 |
help='Timestep limit is max number of timesteps after which the episode will terminate.') |
|
|
199 |
|
|
|
200 |
parser.add_argument('--trajectory_scaling', |
|
|
201 |
type= float, |
|
|
202 |
nargs= '+', |
|
|
203 |
default= None, |
|
|
204 |
help='Adjusts/scales the length of the trajectory') |
|
|
205 |
|
|
|
206 |
parser.add_argument('--center', |
|
|
207 |
type= list_of_list_of_floats, |
|
|
208 |
nargs= '+', |
|
|
209 |
default= None, |
|
|
210 |
help='Adjusts the starting point of the kinematics trajectory') |
|
|
211 |
|
|
|
212 |
parser.add_argument('--stimulus_feedback', |
|
|
213 |
type= boolean_string, |
|
|
214 |
default= False, |
|
|
215 |
help='Experimental stimulus feedback to be included in the sensory feedback') |
|
|
216 |
|
|
|
217 |
parser.add_argument('--proprioceptive_feedback', |
|
|
218 |
type= boolean_string, |
|
|
219 |
default= True, |
|
|
220 |
help='Proprioceptive feedback consists of muscle lengths and velocities') |
|
|
221 |
|
|
|
222 |
parser.add_argument('--muscle_forces', |
|
|
223 |
type= boolean_string, |
|
|
224 |
default= False, |
|
|
225 |
help='Muscle forces consist of appled muscle forces') |
|
|
226 |
|
|
|
227 |
parser.add_argument('--joint_feedback', |
|
|
228 |
type= boolean_string, |
|
|
229 |
default= False, |
|
|
230 |
help='Joint feedback consists of joint positions and velocities') |
|
|
231 |
|
|
|
232 |
parser.add_argument('--visual_feedback', |
|
|
233 |
type= boolean_string, |
|
|
234 |
default= False, |
|
|
235 |
help='Visual feedback consists of x/y/z coordinates of the specified bodies in the model') |
|
|
236 |
|
|
|
237 |
parser.add_argument('--visual_feedback_bodies', |
|
|
238 |
type= list_of_string_names, |
|
|
239 |
nargs= '*', |
|
|
240 |
default= None, |
|
|
241 |
help='Append the names musculo bodies from which visual feedback should be included') |
|
|
242 |
|
|
|
243 |
parser.add_argument('--visual_distance_bodies', |
|
|
244 |
type= list_of_tuples_of_strings, |
|
|
245 |
nargs= '*', |
|
|
246 |
default= None, |
|
|
247 |
help='Specify the names of the bodies as tuples for which the visual distance should be included in the feedback') |
|
|
248 |
|
|
|
249 |
parser.add_argument('--visual_velocity', |
|
|
250 |
type= list_of_string_names, |
|
|
251 |
nargs= '*', |
|
|
252 |
default= None, |
|
|
253 |
help='Specify the names of the bodies for which the visual velocity should be included in the feedback') |
|
|
254 |
|
|
|
255 |
parser.add_argument('--sensory_delay_timepoints', |
|
|
256 |
type= int, |
|
|
257 |
default= 0, |
|
|
258 |
help='Specify the delay in the sensory feedback in terms of the timepoints') |
|
|
259 |
|
|
|
260 |
parser.add_argument('--alpha_usim', |
|
|
261 |
type= float, |
|
|
262 |
default= 0.1, |
|
|
263 |
help='weighting with loss for enforcing simple neural dynamics for uSim/nuSim') |
|
|
264 |
|
|
|
265 |
parser.add_argument('--beta_usim', |
|
|
266 |
type= float, |
|
|
267 |
default= 0.01, |
|
|
268 |
help='weighting with loss for minimizing the neural activations for uSim/nuSim') |
|
|
269 |
|
|
|
270 |
parser.add_argument('--gamma_usim', |
|
|
271 |
type= float, |
|
|
272 |
default= 0.001, |
|
|
273 |
help='weighting with loss for minimizing the synaptic weights for uSim/nuSim') |
|
|
274 |
|
|
|
275 |
parser.add_argument('--zeta_nusim', |
|
|
276 |
type= float, |
|
|
277 |
default= 0, |
|
|
278 |
help='weighting with loss for nuSim constraining a sub-population of RNN units to experimentally recorded neurons for nuSim') |
|
|
279 |
|
|
|
280 |
|
|
|
281 |
return parser |