forked from thousandbrainsproject/tbp.monty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathycb_experiments.py
746 lines (682 loc) · 27.7 KB
/
ycb_experiments.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
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# Copyright 2025 Thousand Brains Project
# Copyright 2022-2024 Numenta Inc.
#
# Copyright may exist in Contributors' modifications
# and/or contributions to the work.
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
import copy
import os
import numpy as np
from tbp.monty.frameworks.config_utils.config_args import (
CSVLoggingConfig,
FiveLMMontySOTAConfig,
MontyArgs,
MotorSystemConfigCurInformedSurfaceGoalStateDriven,
ParallelEvidenceLMLoggingConfig,
PatchAndViewFartherAwaySOTAMontyConfig,
PatchAndViewSOTAMontyConfig,
SurfaceAndViewMontyConfig,
SurfaceAndViewSOTAMontyConfig,
get_cube_face_and_corner_views_rotations,
)
from tbp.monty.frameworks.config_utils.make_dataset_configs import (
EnvironmentDataloaderMultiObjectArgs,
EnvironmentDataloaderPerObjectArgs,
EvalExperimentArgs,
ExperimentArgs,
FiveLMMountHabitatDatasetArgs,
NoisySurfaceViewFinderMountHabitatDatasetArgs,
PatchViewFinderMountHabitatDatasetArgs,
PatchViewFinderMultiObjectMountHabitatDatasetArgs,
PredefinedObjectInitializer,
RandomRotationObjectInitializer,
SurfaceViewFinderMountHabitatDatasetArgs,
get_env_dataloader_per_object_by_idx,
get_object_names_by_idx,
)
from tbp.monty.frameworks.environments import embodied_data as ED
from tbp.monty.frameworks.environments.ycb import (
DISTINCT_OBJECTS,
SIMILAR_OBJECTS,
)
from tbp.monty.frameworks.experiments import MontyObjectRecognitionExperiment
from tbp.monty.frameworks.models.evidence_matching import (
EvidenceGraphLM,
MontyForEvidenceGraphMatching,
)
from tbp.monty.frameworks.models.goal_state_generation import (
EvidenceGoalStateGenerator,
)
from tbp.monty.frameworks.models.sensor_modules import (
DetailedLoggingSM,
FeatureChangeSM,
)
"""
(all use surface-agent models with 0.01 min dist and 64x64 resolution,
feature change SM, 50 min_steps, 500 max_steps)
To generate models run:
- supervised_pre_training_base
- only_surf_agent_training_10obj
- only_surf_agent_training_10simobj
- only_surf_agent_training_allobj
- supervised_pre_training_5lms
- supervised_pre_training_5lms_all_objects
QUICK EVALUATION TESTS:
- 10 objects, 32 known orientations, 1LM, distant agent
- 10 objects, 32 known orientations, 1LM, surface agent
- noise & 10 random rotations, distant agent
- noise & 10 random rotations, distant agent on model learned with distant sensor
- noise & 10 random rotations, surface agent
- no noise & 10 random rotations, surface agent
- noise & 10 random rotations, distant agent, 5LMs
- raw noise & 10 random rotations, surface agent
- 10 similar objects, 32 known orientations, surface agent
- 10 similar objects, noise & 10 random rotations, surface agent
- learning unsupervised
LONGER EVALUATION RUNS:
(all have 77 objects, best policy & paramters optimized for performance)
- default, 32 rotations, distant agent
- noise & 3 random rotations with 1LM, distant agent
- noise & 3 random rotations with 1LM, surface agent
- noise & 3 random rotations with 5LMs
For more details, see docs/how-to-use-monty/running-benchmarks.md
and docs/overview/benchmark-experiments.md
"""
# 14 unique rotations that give good views of the object. Same rotations used
# for supervised pretraining.
test_rotations_all = get_cube_face_and_corner_views_rotations()
# Limited number of rotations to use for quicker evaluation when doing longer
# runs with all 77 YCB objects.
test_rotations_3 = test_rotations_all[:3]
monty_models_dir = os.getenv("MONTY_MODELS")
# v6 : Using TLS for point-normal estimation
# v7 : Updated for State class support + using new feature names like pose_vectors
# v8 : Using separate graph per input channel
# v9 : Using models trained on 14 unique rotations
# v10 : Using models trained without the semantic sensor
fe_pretrain_dir = os.path.expanduser(
os.path.join(monty_models_dir, "pretrained_ycb_v10")
)
model_path_10distinctobj = os.path.join(
fe_pretrain_dir,
"surf_agent_1lm_10distinctobj/pretrained/",
)
dist_agent_model_path_10distinctobj = os.path.join(
fe_pretrain_dir,
"supervised_pre_training_base/pretrained/",
)
model_path_10simobj = os.path.join(
fe_pretrain_dir,
"surf_agent_1lm_10similarobj/pretrained/",
)
model_path_5lms_10distinctobj = os.path.join(
fe_pretrain_dir,
"supervised_pre_training_5lms/pretrained/",
)
model_path_1lm_77obj = os.path.join(
fe_pretrain_dir,
"surf_agent_1lm_77obj/pretrained/",
)
model_path_5lms_77obj = os.path.join(
fe_pretrain_dir,
"supervised_pre_training_5lms_all_objects/pretrained/",
)
# NOTE: maybe lower once we have better policies
# Is not really nescessary for good performance but makes sure we don't just overfit
# on the first few points.
min_eval_steps = 20
default_tolerance_values = {
"hsv": np.array([0.1, 0.2, 0.2]),
"principal_curvatures_log": np.ones(2),
}
default_tolerances = {
"patch": default_tolerance_values
} # features where weight is not specified default weight to 1
# Everything is weighted 1, except for saturation and value which are not used.
default_feature_weights = {
"patch": {
# Weighting saturation and value less since these might change under different
# lighting conditions. In the future we can extract better features in the SM
# such as relative value changes.
"hsv": np.array([1, 0.5, 0.5]),
}
}
default_evidence_lm_config = dict(
learning_module_class=EvidenceGraphLM,
learning_module_args=dict(
# mmd of 0.015 get higher performance but slower run time
max_match_distance=0.01, # =1cm
tolerances=default_tolerances,
feature_weights=default_feature_weights,
# smaller threshold reduces runtime but also performance
x_percent_threshold=20,
# Using a smaller max_nneighbors (5 instead of 10) makes runtime faster,
# but reduces performance a bit
max_nneighbors=10,
# Use this to update all hypotheses at every step as previously
# evidence_update_threshold="all",
# Use this to update all hypotheses > x_percent_threshold (faster)
evidence_update_threshold="x_percent_threshold",
# use_multithreading=False,
# NOTE: Currently not used when loading pretrained graphs.
max_graph_size=0.3, # 30cm
num_model_voxels_per_dim=100,
gsg_class=EvidenceGoalStateGenerator,
gsg_args=dict(
goal_tolerances=dict(
location=0.015, # distance in meters
), # Tolerance(s) when determining goal-state success
elapsed_steps_factor=10, # Factor that considers the number of elapsed
# steps as a possible condition for initiating a hypothesis-testing goal
# state; should be set to an integer reflecting a number of steps
min_post_goal_success_steps=5, # Number of necessary steps for a hypothesis
# goal-state to be considered
x_percent_scale_factor=0.75, # Scale x-percent threshold to decide
# when we should focus on pose rather than determining object ID; should
# be bounded between 0:1.0; "mod" for modifier
desired_object_distance=0.03, # Distance from the object to the
# agent that is considered "close enough" to the object
),
),
)
# Default configs for surface policy which has a different desired object distance
default_surf_evidence_lm_config = copy.deepcopy(default_evidence_lm_config)
default_surf_evidence_lm_config["learning_module_args"]["gsg_args"][
"desired_object_distance"
] = 0.025
# Using a smaller max_nneighbors for the noiseless experiments cuts the runtime
# in almost half without negatively affecting performance. For the noisy experiments a
# higher max_nneighbors is necessary so we use the default config above for
# those.
lower_max_nneighbors_lm_config = copy.deepcopy(default_evidence_lm_config)
lower_max_nneighbors_lm_config["learning_module_args"]["max_nneighbors"] = 5
lower_max_nneighbors_surf_lm_config = copy.deepcopy(default_surf_evidence_lm_config)
lower_max_nneighbors_surf_lm_config["learning_module_args"]["max_nneighbors"] = 5
default_evidence_1lm_config = dict(learning_module_0=default_evidence_lm_config)
lower_max_nneighbors_1lm_config = dict(learning_module_0=lower_max_nneighbors_lm_config)
default_evidence_surf_1lm_config = dict(
learning_module_0=default_surf_evidence_lm_config
)
lower_max_nneighbors_surf_1lm_config = dict(
learning_module_0=lower_max_nneighbors_surf_lm_config
)
lm0_config = copy.deepcopy(default_evidence_lm_config)
lm0_config["learning_module_args"]["tolerances"] = {"patch_0": default_tolerance_values}
lm1_config = copy.deepcopy(default_evidence_lm_config)
lm1_config["learning_module_args"]["tolerances"] = {"patch_1": default_tolerance_values}
lm2_config = copy.deepcopy(default_evidence_lm_config)
lm2_config["learning_module_args"]["tolerances"] = {"patch_2": default_tolerance_values}
lm3_config = copy.deepcopy(default_evidence_lm_config)
lm3_config["learning_module_args"]["tolerances"] = {"patch_3": default_tolerance_values}
lm4_config = copy.deepcopy(default_evidence_lm_config)
lm4_config["learning_module_args"]["tolerances"] = {"patch_4": default_tolerance_values}
default_5lm_lmconfig = dict(
learning_module_0=lm0_config,
learning_module_1=lm1_config,
learning_module_2=lm2_config,
learning_module_3=lm3_config,
learning_module_4=lm4_config,
)
default_sensor_features = [
"pose_vectors",
"pose_fully_defined",
"on_object",
"hsv",
"principal_curvatures_log",
]
default_sensor_features_surf_agent = [
"pose_vectors",
"pose_fully_defined",
"on_object",
"object_coverage",
"min_depth",
"mean_depth",
"hsv",
"principal_curvatures",
"principal_curvatures_log",
]
default_all_noise_params = {
"features": {
"pose_vectors": 2, # rotate by random degrees along xyz
"hsv": 0.1, # add gaussian noise with 0.1 std
"principal_curvatures_log": 0.1,
"pose_fully_defined": 0.01, # flip bool in 1% of cases
},
"location": 0.002, # add gaussian noise with 0.002 std
}
default_all_noisy_sensor_module = dict(
sensor_module_class=FeatureChangeSM,
sensor_module_args=dict(
sensor_module_id="patch",
features=default_sensor_features,
save_raw_obs=False,
delta_thresholds={
"on_object": 0,
"distance": 0.01,
},
noise_params=default_all_noise_params,
),
)
default_all_noisy_surf_agent_sensor_module = dict(
sensor_module_class=FeatureChangeSM,
sensor_module_args=dict(
sensor_module_id="patch",
features=default_sensor_features_surf_agent,
save_raw_obs=False,
delta_thresholds={
"on_object": 0,
"distance": 0.01,
},
surf_agent_sm=True,
noise_params=default_all_noise_params,
),
)
sm0_config = copy.deepcopy(default_all_noisy_sensor_module)
sm0_config["sensor_module_args"]["sensor_module_id"] = "patch_0"
sm1_config = copy.deepcopy(default_all_noisy_sensor_module)
sm1_config["sensor_module_args"]["sensor_module_id"] = "patch_1"
sm2_config = copy.deepcopy(default_all_noisy_sensor_module)
sm2_config["sensor_module_args"]["sensor_module_id"] = "patch_2"
sm3_config = copy.deepcopy(default_all_noisy_sensor_module)
sm3_config["sensor_module_args"]["sensor_module_id"] = "patch_3"
sm4_config = copy.deepcopy(default_all_noisy_sensor_module)
sm4_config["sensor_module_args"]["sensor_module_id"] = "patch_4"
default_5sm_config = dict(
sensor_module_0=sm0_config,
sensor_module_1=sm1_config,
sensor_module_2=sm2_config,
sensor_module_3=sm3_config,
sensor_module_4=sm4_config,
sensor_module_5=dict(
sensor_module_class=DetailedLoggingSM,
sensor_module_args=dict(
sensor_module_id="view_finder",
save_raw_obs=True,
),
),
)
base_config_10distinctobj_dist_agent = dict(
experiment_class=MontyObjectRecognitionExperiment,
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_10distinctobj,
n_eval_epochs=len(test_rotations_all),
),
logging_config=ParallelEvidenceLMLoggingConfig(
wandb_group="benchmark_experiments",
# Comment in for quick debugging (turns of wandb and increases logging)
# wandb_handlers=[],
# python_log_level="DEBUG",
),
monty_config=PatchAndViewSOTAMontyConfig(
learning_module_configs=lower_max_nneighbors_1lm_config,
monty_args=MontyArgs(min_eval_steps=min_eval_steps),
),
dataset_class=ED.EnvironmentDataset,
dataset_args=PatchViewFinderMountHabitatDatasetArgs(),
train_dataloader_class=ED.InformedEnvironmentDataLoader,
train_dataloader_args=get_env_dataloader_per_object_by_idx(start=0, stop=10),
eval_dataloader_class=ED.InformedEnvironmentDataLoader,
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(0, 10, object_list=DISTINCT_OBJECTS),
object_init_sampler=PredefinedObjectInitializer(rotations=test_rotations_all),
),
)
base_config_10distinctobj_surf_agent = copy.deepcopy(
base_config_10distinctobj_dist_agent
)
base_config_10distinctobj_surf_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_10distinctobj,
n_eval_epochs=len(test_rotations_all),
max_total_steps=5000, # x4 max_eval_steps for surface-policy, x2.5 for
# feature-change SM
),
monty_config=SurfaceAndViewSOTAMontyConfig(
learning_module_configs=lower_max_nneighbors_surf_1lm_config,
motor_system_config=MotorSystemConfigCurInformedSurfaceGoalStateDriven(),
monty_args=MontyArgs(min_eval_steps=min_eval_steps),
),
dataset_args=SurfaceViewFinderMountHabitatDatasetArgs(),
)
randrot_noise_10distinctobj_dist_agent = copy.deepcopy(
base_config_10distinctobj_dist_agent
)
randrot_noise_10distinctobj_dist_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_10distinctobj,
n_eval_epochs=10, # number of random rotations to test for each object
),
monty_config=PatchAndViewSOTAMontyConfig(
sensor_module_configs=dict(
sensor_module_0=default_all_noisy_sensor_module,
sensor_module_1=dict(
sensor_module_class=DetailedLoggingSM,
sensor_module_args=dict(
sensor_module_id="view_finder",
save_raw_obs=True,
),
),
),
learning_module_configs=default_evidence_1lm_config,
monty_args=MontyArgs(min_eval_steps=min_eval_steps),
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(0, 10, object_list=DISTINCT_OBJECTS),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
# NOTE: This experiment can reach a higher accuracy when using a 10% TH.
randrot_noise_10distinctobj_dist_on_distm = copy.deepcopy(
randrot_noise_10distinctobj_dist_agent
)
randrot_noise_10distinctobj_dist_on_distm.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=dist_agent_model_path_10distinctobj,
n_eval_epochs=10,
),
)
randrot_noise_10distinctobj_surf_agent = copy.deepcopy(
randrot_noise_10distinctobj_dist_agent
)
randrot_noise_10distinctobj_surf_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_10distinctobj,
n_eval_epochs=10,
max_total_steps=5000, # x4 max_eval_steps for surface-policy, x2.5 for
# feature-change SM
),
monty_config=SurfaceAndViewSOTAMontyConfig(
sensor_module_configs=dict(
sensor_module_0=default_all_noisy_surf_agent_sensor_module,
sensor_module_1=dict(
sensor_module_class=DetailedLoggingSM,
sensor_module_args=dict(
sensor_module_id="view_finder",
save_raw_obs=True,
),
),
),
learning_module_configs=default_evidence_surf_1lm_config,
motor_system_config=MotorSystemConfigCurInformedSurfaceGoalStateDriven(),
monty_args=MontyArgs(min_eval_steps=min_eval_steps),
),
dataset_args=SurfaceViewFinderMountHabitatDatasetArgs(),
)
randrot_10distinctobj_surf_agent = copy.deepcopy(base_config_10distinctobj_surf_agent)
randrot_10distinctobj_surf_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_10distinctobj,
n_eval_epochs=10,
max_total_steps=5000,
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(0, 10, object_list=DISTINCT_OBJECTS),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
randrot_noise_10distinctobj_5lms_dist_agent = copy.deepcopy(
randrot_noise_10distinctobj_dist_agent
)
randrot_noise_10distinctobj_5lms_dist_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_5lms_10distinctobj,
n_eval_epochs=10,
min_lms_match=3,
),
monty_config=FiveLMMontySOTAConfig(
monty_class=MontyForEvidenceGraphMatching, # has custom evidence voting method
learning_module_configs=default_5lm_lmconfig,
sensor_module_configs=default_5sm_config,
monty_args=MontyArgs(min_eval_steps=min_eval_steps),
),
dataset_args=FiveLMMountHabitatDatasetArgs(),
)
base_10simobj_surf_agent = copy.deepcopy(base_config_10distinctobj_surf_agent)
base_10simobj_surf_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_10simobj,
n_eval_epochs=len(test_rotations_all),
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(0, 10, object_list=SIMILAR_OBJECTS),
object_init_sampler=PredefinedObjectInitializer(rotations=test_rotations_all),
),
)
randrot_noise_10simobj_surf_agent = copy.deepcopy(
randrot_noise_10distinctobj_surf_agent
)
randrot_noise_10simobj_surf_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_10simobj,
n_eval_epochs=10, # number of random rotations to test for each object
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(0, 10, object_list=SIMILAR_OBJECTS),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
randrot_noise_10simobj_dist_agent = copy.deepcopy(
randrot_noise_10distinctobj_dist_agent
)
randrot_noise_10simobj_dist_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_10simobj,
n_eval_epochs=10, # number of random rotations to test for each object
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(0, 10, object_list=SIMILAR_OBJECTS),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
randomrot_rawnoise_10distinctobj_surf_agent = copy.deepcopy(
randrot_noise_10distinctobj_surf_agent
)
randomrot_rawnoise_10distinctobj_surf_agent.update(
dataset_args=NoisySurfaceViewFinderMountHabitatDatasetArgs(),
)
# Experiment with multiple (distractor objects)
base_10multi_distinctobj_dist_agent = copy.deepcopy(
base_config_10distinctobj_dist_agent
)
base_10multi_distinctobj_dist_agent.update(
# Agent is farther from object and takes larger steps to increase chance of
# landing on other objects; uses hypothesis-testing policy (which may also cause
# it to land on other objects)
monty_config=PatchAndViewFartherAwaySOTAMontyConfig(
learning_module_configs=lower_max_nneighbors_1lm_config,
monty_args=MontyArgs(min_eval_steps=min_eval_steps),
),
dataset_args=PatchViewFinderMultiObjectMountHabitatDatasetArgs(),
eval_dataloader_args=EnvironmentDataloaderMultiObjectArgs(
object_names=dict(
targets_list=get_object_names_by_idx(0, 10, object_list=DISTINCT_OBJECTS),
source_object_list=DISTINCT_OBJECTS,
num_distractors=10, # Number of other objects added to the environment
),
object_init_sampler=PredefinedObjectInitializer(rotations=test_rotations_all),
),
)
# ----- Learning Unsupervised -----
default_lfs_lm = dict(
learning_module_0=dict(
learning_module_class=EvidenceGraphLM,
learning_module_args=dict(
max_match_distance=0.01,
tolerances=default_tolerances,
feature_weights=default_feature_weights,
# Higher threshold to avoid too many false positives during the first
# episodes. In the future we may consider some kind of learning schedule
x_percent_threshold=50,
graph_delta_thresholds=dict(
patch=dict(
distance=0.01,
pose_vectors=[np.pi / 8, np.pi * 2, np.pi * 2],
principal_curvatures_log=[1.0, 1.0],
hsv=[0.1, 1, 1],
)
),
# Since we have 100 min steps we want these steps to have been consistent
# with the mlh. If we keep this value at its default (1) it often happens
# that the episode just terminates once min steps is reached. Again, we
# try to avoid too many false positive in the first epochs.
object_evidence_threshold=100,
# Also the symmetry evidence increments a lot after 100 steps and easily
# reaches the default required evidence. Again, these are temporary fixes
# and we will probably want some more stable long term solutions.
required_symmetry_evidence=20,
max_nneighbors=5,
),
)
)
# NOTE: Using the MotorSystemConfigCurvatureInformedSurface does not work so well
# in this setting and currently leads to more confused objects.
surf_agent_unsupervised_10distinctobj = copy.deepcopy(
base_config_10distinctobj_dist_agent
)
surf_agent_unsupervised_10distinctobj.update(
experiment_args=ExperimentArgs(
do_eval=False,
n_train_epochs=10,
max_train_steps=4000,
max_total_steps=4000,
),
logging_config=CSVLoggingConfig(python_log_level="INFO"),
monty_config=SurfaceAndViewMontyConfig(
monty_args=MontyArgs(num_exploratory_steps=1000, min_train_steps=100),
learning_module_configs=default_lfs_lm,
),
dataset_args=SurfaceViewFinderMountHabitatDatasetArgs(),
train_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(0, 10, object_list=DISTINCT_OBJECTS),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
surf_agent_unsupervised_10distinctobj_noise = copy.deepcopy(
surf_agent_unsupervised_10distinctobj
)
surf_agent_unsupervised_10distinctobj_noise.update(
monty_config=SurfaceAndViewMontyConfig(
monty_args=MontyArgs(num_exploratory_steps=1000, min_train_steps=100),
sensor_module_configs=dict(
sensor_module_0=default_all_noisy_surf_agent_sensor_module,
sensor_module_1=dict(
sensor_module_class=DetailedLoggingSM,
sensor_module_args=dict(
sensor_module_id="view_finder",
save_raw_obs=True,
),
),
),
learning_module_configs=default_lfs_lm,
)
)
surf_agent_unsupervised_10simobj = copy.deepcopy(surf_agent_unsupervised_10distinctobj)
surf_agent_unsupervised_10simobj.update(
train_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(0, 10, object_list=SIMILAR_OBJECTS),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
# --------- Long Runs ----------------
base_77obj_dist_agent = copy.deepcopy(base_config_10distinctobj_dist_agent)
base_77obj_dist_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_1lm_77obj,
n_eval_epochs=len(test_rotations_3),
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(
0,
77,
),
object_init_sampler=PredefinedObjectInitializer(rotations=test_rotations_3),
),
)
base_77obj_surf_agent = copy.deepcopy(base_config_10distinctobj_surf_agent)
base_77obj_surf_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_1lm_77obj,
n_eval_epochs=len(test_rotations_3),
max_total_steps=5000,
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(
0,
77,
),
object_init_sampler=PredefinedObjectInitializer(rotations=test_rotations_3),
),
)
randrot_noise_77obj_surf_agent = copy.deepcopy(randrot_noise_10distinctobj_surf_agent)
randrot_noise_77obj_surf_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_1lm_77obj,
n_eval_epochs=3,
max_total_steps=5000,
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(
0,
77,
),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
randrot_noise_77obj_dist_agent = copy.deepcopy(randrot_noise_10distinctobj_dist_agent)
randrot_noise_77obj_dist_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_1lm_77obj,
n_eval_epochs=3,
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(
0,
77,
),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
randrot_noise_77obj_5lms_dist_agent = copy.deepcopy(
randrot_noise_10distinctobj_5lms_dist_agent
)
randrot_noise_77obj_5lms_dist_agent.update(
experiment_args=EvalExperimentArgs(
model_name_or_path=model_path_5lms_77obj,
n_eval_epochs=1,
min_lms_match=3,
),
eval_dataloader_args=EnvironmentDataloaderPerObjectArgs(
object_names=get_object_names_by_idx(
0,
77,
),
object_init_sampler=RandomRotationObjectInitializer(),
),
)
CONFIGS = dict(
base_config_10distinctobj_dist_agent=base_config_10distinctobj_dist_agent,
base_config_10distinctobj_surf_agent=base_config_10distinctobj_surf_agent,
randrot_noise_10distinctobj_dist_agent=randrot_noise_10distinctobj_dist_agent,
randrot_noise_10distinctobj_dist_on_distm=randrot_noise_10distinctobj_dist_on_distm,
randrot_noise_10distinctobj_surf_agent=randrot_noise_10distinctobj_surf_agent,
randrot_10distinctobj_surf_agent=randrot_10distinctobj_surf_agent,
randrot_noise_10distinctobj_5lms_dist_agent=randrot_noise_10distinctobj_5lms_dist_agent,
base_10simobj_surf_agent=base_10simobj_surf_agent,
randrot_noise_10simobj_surf_agent=randrot_noise_10simobj_surf_agent,
randrot_noise_10simobj_dist_agent=randrot_noise_10simobj_dist_agent,
randomrot_rawnoise_10distinctobj_surf_agent=randomrot_rawnoise_10distinctobj_surf_agent,
base_10multi_distinctobj_dist_agent=base_10multi_distinctobj_dist_agent,
# ------------- Not yet evaluated -------------
surf_agent_unsupervised_10distinctobj=surf_agent_unsupervised_10distinctobj,
surf_agent_unsupervised_10distinctobj_noise=surf_agent_unsupervised_10distinctobj_noise,
surf_agent_unsupervised_10simobj=surf_agent_unsupervised_10simobj,
# ------------- long runs with all objects -------------
base_77obj_dist_agent=base_77obj_dist_agent,
base_77obj_surf_agent=base_77obj_surf_agent,
randrot_noise_77obj_surf_agent=randrot_noise_77obj_surf_agent,
randrot_noise_77obj_dist_agent=randrot_noise_77obj_dist_agent,
randrot_noise_77obj_5lms_dist_agent=randrot_noise_77obj_5lms_dist_agent,
)