[9f010e]: / config.py

Download this file

282 lines (219 with data), 11.5 kB

  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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import configargparse
def list_of_list_of_floats(x):
temp = x.replace('[', '').replace(']', '').split(',')
temp2 = [float(temp_e) for temp_e in temp]
return temp2
def list_of_string_names(x):
return x
def list_of_tuples_of_strings(x):
temp = x.replace('[', '').replace(']', '').split(';')
return temp
def boolean_string(s):
if s not in {'False', 'True'}:
raise ValueError('Not a valid boolean string')
return s == 'True'
def config_parser():
parser = configargparse.ArgumentParser()
parser.add_argument("--config", is_config_file=True, help="config file path")
parser.add_argument('--model',
type=str,
default="rnn",
help='rnn, gru')
parser.add_argument('--gamma',
type=float,
default=0.99,
help='discount factor for reward (default: 0.99)')
parser.add_argument('--tau',
type=float,
default=0.005,
help='target smoothing coefficient(τ) (default: 0.005)')
parser.add_argument('--lr',
type=float,
default=0.0003,
help='learning rate (default: 0.001)')
parser.add_argument('--alpha',
type=float,
default=0.2,
help='Temperature parameter α determines the relative importance of the entropy\
term against the reward (default: 0.2)')
parser.add_argument('--automatic_entropy_tuning',
type=boolean_string,
default=True,
help='Automaically adjust α (default: False)')
parser.add_argument('--seed',
type=int,
default=123456,
help='random seed (default: 123456)')
parser.add_argument('--policy_batch_size',
type=int,
default=8,
help='batch size (default: 8)')
parser.add_argument('--hidden_size',
type=int,
default=256,
help='hidden size (default: 1000)')
parser.add_argument('--policy_replay_size',
type=int,
default=50000,
help='size of replay buffer (default: 2800)')
parser.add_argument('--multi_policy_loss',
type=boolean_string,
default=False,
help='use additional policy losses')
parser.add_argument('--batch_iters',
type=int,
default=1,
help='iterations to apply update')
parser.add_argument('--cuda',
action="store_true",
help='run on CUDA (default: False)')
parser.add_argument('--visualize',
type=boolean_string,
default=False,
help='visualize monkey/mouse')
parser.add_argument('--root_dir',
type=str,
default='',
help='specify you root directory')
parser.add_argument('--checkpoint_file',
type=str,
default='agent_networks',
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')
parser.add_argument('--checkpoint_folder',
type=str,
default= 'checkpoint',
help='specify the name of the folder in which you would like to save the checkpoint file')
parser.add_argument('--statistics_folder',
type=str,
default= 'training_statistics',
help='specify the name of the folder in which you would like to save the training statistics')
parser.add_argument('--total_episodes',
type=int,
default=5000000,
help='total number of episodes')
parser.add_argument('--save_iter',
type=int,
default=100,
help='number of episodes until checkpoint is saved')
parser.add_argument('--mode',
type=str,
default="train",
help='select whether to train or test a model (train, test, SFE, sensory_pert, neural_pert, musculo_properties)')
parser.add_argument('--verbose_training',
type=boolean_string,
default=False,
help='Print statistics during training')
parser.add_argument('--load_saved_nets_for_training',
type=boolean_string,
default=False,
help='select whether to train or test a model (train, test)')
parser.add_argument('--musculoskeletal_model_path',
type=str,
default='musculoskeletal_model/musculoskeletal_model.xml',
help='path of musculoskeletal model')
parser.add_argument('--initial_pose_path',
type=str,
default='initial_pose',
help='path of musculoskeletal model')
parser.add_argument('--kinematics_path',
type=str,
default='kinematics_data',
help='path to kinematics data')
parser.add_argument('--nusim_data_path',
type=str,
default='nusim_neural_data',
help='path to nusim neural data for training and testing')
parser.add_argument('--stimulus_data_path',
type=str,
default='stimulus_data',
help='path to experimental stimulus data for training and testing')
parser.add_argument('--test_data_filename',
type=str,
default='test_data',
help='filename for saving the testing data')
parser.add_argument('--condition_selection_strategy',
type=str,
default='reward',
help='whether to select the next condition based on the corresponding average reward accumulated so far')
parser.add_argument('--sim_dt',
type=int,
default=0,
help='The timestep for the simulation: Keep 0 for default simulation timestep')
parser.add_argument('--frame_repeat',
type=int,
default=5,
help='The frames/timepoints for which the same action should be repeated during training of the agent')
parser.add_argument('--n_fixedsteps',
type=int,
default=25,
help='The target will remain at kinematic[timestep=0] for n_fixedsteps')
parser.add_argument('--timestep_limit',
type=int,
default=1000,
help='Timestep limit is max number of timesteps after which the episode will terminate.')
parser.add_argument('--trajectory_scaling',
type= float,
nargs= '+',
default= None,
help='Adjusts/scales the length of the trajectory')
parser.add_argument('--center',
type= list_of_list_of_floats,
nargs= '+',
default= None,
help='Adjusts the starting point of the kinematics trajectory')
parser.add_argument('--stimulus_feedback',
type= boolean_string,
default= False,
help='Experimental stimulus feedback to be included in the sensory feedback')
parser.add_argument('--proprioceptive_feedback',
type= boolean_string,
default= True,
help='Proprioceptive feedback consists of muscle lengths and velocities')
parser.add_argument('--muscle_forces',
type= boolean_string,
default= False,
help='Muscle forces consist of appled muscle forces')
parser.add_argument('--joint_feedback',
type= boolean_string,
default= False,
help='Joint feedback consists of joint positions and velocities')
parser.add_argument('--visual_feedback',
type= boolean_string,
default= False,
help='Visual feedback consists of x/y/z coordinates of the specified bodies in the model')
parser.add_argument('--visual_feedback_bodies',
type= list_of_string_names,
nargs= '*',
default= None,
help='Append the names musculo bodies from which visual feedback should be included')
parser.add_argument('--visual_distance_bodies',
type= list_of_tuples_of_strings,
nargs= '*',
default= None,
help='Specify the names of the bodies as tuples for which the visual distance should be included in the feedback')
parser.add_argument('--visual_velocity',
type= list_of_string_names,
nargs= '*',
default= None,
help='Specify the names of the bodies for which the visual velocity should be included in the feedback')
parser.add_argument('--sensory_delay_timepoints',
type= int,
default= 0,
help='Specify the delay in the sensory feedback in terms of the timepoints')
parser.add_argument('--alpha_usim',
type= float,
default= 0.1,
help='weighting with loss for enforcing simple neural dynamics for uSim/nuSim')
parser.add_argument('--beta_usim',
type= float,
default= 0.01,
help='weighting with loss for minimizing the neural activations for uSim/nuSim')
parser.add_argument('--gamma_usim',
type= float,
default= 0.001,
help='weighting with loss for minimizing the synaptic weights for uSim/nuSim')
parser.add_argument('--zeta_nusim',
type= float,
default= 0,
help='weighting with loss for nuSim constraining a sub-population of RNN units to experimentally recorded neurons for nuSim')
return parser