-
Notifications
You must be signed in to change notification settings - Fork 271
Expand file tree
/
Copy pathfinetune_config.py
More file actions
163 lines (151 loc) · 5.53 KB
/
finetune_config.py
File metadata and controls
163 lines (151 loc) · 5.53 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
from ml_collections import ConfigDict
from ml_collections.config_dict import FieldReference, placeholder
from octo.utils.spec import ModuleSpec
def get_config(config_string="full,multimodal"):
mode, task = config_string.split(",")
assert task in ["image_conditioned", "language_conditioned", "multimodal"]
assert mode in ["full", "head_only", "head_mlp_only"]
# Fill this in for your own dataset!
# There should be two image keys
# first image key should be the third-person view (None if not used)
# and second image key should be the wrist view (None if not used)
FINETUNING_KWARGS = {
"name": "bridge_dataset",
"data_dir": "./tests/debug_dataset",
"image_obs_keys": {"primary": "image_0", "wrist": None},
"proprio_obs_key": "proprio",
"language_key": "language_instruction",
"action_proprio_normalization_type": "normal",
# We want to avoid normalizing the gripper
"action_normalization_mask": [True, True, True, True, True, True, False],
# standardize_fn is dynamically loaded from a file
# for example: "experiments/kevin/custom_standardization_transforms.py:aloha_dataset_transform"
"standardize_fn": ModuleSpec.create(
"octo.data.oxe.oxe_standardization_transforms:bridge_dataset_transform",
),
# If the default data loading speed is too slow, try these:
# "num_parallel_reads": 8, # for reading from disk / GCS
# "num_parallel_calls": 16, # for initial dataset construction
}
if mode == "full":
frozen_keys = None
elif mode == "head_only":
frozen_keys = ("octo_transformer.*",)
elif mode == "head_mlp_only":
frozen_keys = (
"octo_transformer.*",
"heads_*.map_head.probe",
"heads_*.map_head.MultiHeadDotProductAttention_0.*",
)
else:
raise ValueError("Invalid mode")
max_steps = FieldReference(50000)
window_size = FieldReference(default=1)
config = dict(
pretrained_path=placeholder(str),
pretrained_step=placeholder(int),
batch_size=256,
shuffle_buffer_size=10000,
num_steps=max_steps,
log_interval=100,
eval_interval=5000,
save_interval=5000,
save_dir=placeholder(str),
seed=42,
wandb=dict(
project="octo_finetune", group=placeholder(str), entity=placeholder(str)
),
dataset_kwargs=FINETUNING_KWARGS,
modality=task,
finetuning_mode=mode,
window_size=window_size,
optimizer=dict(
learning_rate=dict(
name="cosine",
init_value=0.0,
peak_value=3e-4,
warmup_steps=2000,
decay_steps=max_steps,
end_value=0.0,
),
weight_decay=0.01,
clip_gradient=1.0,
frozen_keys=frozen_keys,
grad_accumulation_steps=None, # if you are using grad accumulation, you need to adjust max_steps accordingly
),
val_kwargs=dict(
val_shuffle_buffer_size=1000,
num_val_batches=16,
),
viz_kwargs=dict(
eval_batch_size=128,
trajs_for_metrics=100,
trajs_for_viz=8,
samples_per_state=8,
),
)
if task == "image_conditioned":
goal_relabeling_strategy = "uniform"
keep_image_prob = 1.0
elif task == "language_conditioned":
goal_relabeling_strategy = None
keep_image_prob = 0.0
elif task == "multimodal":
goal_relabeling_strategy = "uniform"
keep_image_prob = 0.5
else:
raise ValueError("Invalid modality")
traj_transform_kwargs = dict(
window_size=window_size,
action_horizon=4,
goal_relabeling_strategy=goal_relabeling_strategy,
task_augment_strategy="delete_task_conditioning",
task_augment_kwargs=dict(
keep_image_prob=keep_image_prob,
),
# If the default data loading speed is too slow, try these:
# num_parallel_calls=16, # for less CPU-intensive ops
)
workspace_augment_kwargs = dict(
random_resized_crop=dict(scale=[0.8, 1.0], ratio=[0.9, 1.1]),
random_brightness=[0.1],
random_contrast=[0.9, 1.1],
random_saturation=[0.9, 1.1],
random_hue=[0.05],
augment_order=[
"random_resized_crop",
"random_brightness",
"random_contrast",
"random_saturation",
"random_hue",
],
)
wrist_augment_kwargs = dict(
random_brightness=[0.1],
random_contrast=[0.9, 1.1],
random_saturation=[0.9, 1.1],
random_hue=[0.05],
augment_order=[
"random_brightness",
"random_contrast",
"random_saturation",
"random_hue",
],
)
frame_transform_kwargs = dict(
resize_size={
"primary": (256, 256), # workspace (3rd person) camera is at 256x256
"wrist": (128, 128), # wrist camera is at 128x128
},
image_augment_kwargs=dict(
primary=workspace_augment_kwargs,
wrist=wrist_augment_kwargs,
),
)
# If the default data loading speed is too slow, try these:
config[
"frame_transform_threads"
] = 16 # for the most CPU-intensive ops (decoding, resizing, augmenting)
config["traj_transform_kwargs"] = traj_transform_kwargs
config["frame_transform_kwargs"] = frame_transform_kwargs
return ConfigDict(config)