Skip to content

Commit 1a93a4a

Browse files
author
Yanchao Sun
committed
rtg datamodule fixed
1 parent 0ae4006 commit 1a93a4a

4 files changed

Lines changed: 10 additions & 49 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ python src/dmc_downstream.py \
170170
data.num_steps=1000000 \
171171
domain_and_task.domain=${DOMAIN} \
172172
domain_and_task.task=${TASK} \
173-
model.model_type=reward_conditioned
174-
data.rand_select=False
173+
model.model_type=reward_conditioned \
174+
data.rand_select=True \
175175
no_load_action=True \
176176
load_model_from=./outputs/pretrain_explore/checkpoints/last.ckpt \
177177
output_dir=./outputs/${DOMAIN}_${TASK}_bc/

configs/downstream.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ data:
6666
num_workers: 1
6767
train_replay_id: 1
6868
val_replay_id: 2
69-
70-
# used for DMCBCDataModule only (used when model_type is "naive")
71-
select_rate: 0
72-
rand_select: False
69+
select_rate: 0.1
70+
rand_select: False # True for reward-conditioned learning
7371

7472
# DTModel
7573
model:

src/datamodules/dmc_datamodule.py

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,7 @@ def __getitem__(self, idx):
240240

241241

242242
class DMCDataModule(LightningDataModule):
243-
"""Example of LightningDataModule for Atari DQN Replay Buffer dataset.
244-
245-
A DataModule implements 5 key methods:
246-
- prepare_data (things to do on 1 GPU/TPU, not on every GPU/TPU in distributed mode)
247-
- setup (things to do on every accelerator in distributed mode)
248-
- train_dataloader (the training dataloader)
249-
- val_dataloader (the validation dataloader(s))
250-
- test_dataloader (the test dataloader(s))
251-
252-
This allows you to share a full dataset without explaining how to download,
253-
split, transform and process the data.
254-
255-
Read the docs:
256-
https://pytorch-lightning.readthedocs.io/en/latest/extensions/datamodules.html
243+
"""DMC Dataset for one specific domain and task.
257244
"""
258245

259246
def __init__(
@@ -369,32 +356,12 @@ def val_dataloader(self):
369356

370357
def test_dataloader(self):
371358
return None
372-
# return DataLoader(
373-
# self.test_dataset,
374-
# shuffle=False,
375-
# pin_memory=True,
376-
# batch_size=self.hparams.batch_size,
377-
# num_workers=self.hparams.num_workers,
378-
# persistent_workers=True
379-
# )
380359

381360

382361
class DMCBCDataModule(LightningDataModule):
383-
"""Example of LightningDataModule for behavior cloning on DMC. Only top 10 percent trajectories
384-
are used.
385-
386-
A DataModule implements 5 key methods:
387-
- prepare_data (things to do on 1 GPU/TPU, not on every GPU/TPU in distributed mode)
388-
- setup (things to do on every accelerator in distributed mode)
389-
- train_dataloader (the training dataloader)
390-
- val_dataloader (the validation dataloader(s))
391-
- test_dataloader (the test dataloader(s))
392-
393-
This allows you to share a full dataset without explaining how to download,
394-
split, transform and process the data.
395-
396-
Read the docs:
397-
https://pytorch-lightning.readthedocs.io/en/latest/extensions/datamodules.html
362+
"""DMC dataset on one specific domain and task with data subsampling.
363+
For behavior cloning: only top k percent trajectories (expert data) are used.
364+
For reward-conditioned learning: randomly selected k percent trajectories are used.
398365
"""
399366

400367
def __init__(
@@ -412,7 +379,7 @@ def __init__(
412379
train_replay_id=1,
413380
val_replay_id=2,
414381
select_rate=0.1,
415-
rand_select=False,
382+
rand_select=False, # True for reward-conditioned learning
416383
):
417384
super().__init__()
418385

src/dmc_downstream.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
def main(cfg):
1414
cfg_dict = OmegaConf.to_container(cfg, resolve=True)
1515

16-
if cfg.model.model_type == "naive":
17-
# bc = True
18-
dmc_data = DMCBCDataModule(**cfg.data)
19-
else:
20-
dmc_data = DMCDataModule(**cfg.data)
16+
dmc_data = DMCBCDataModule(**cfg.data)
2117

2218
model = pl_utils.instantiate_class(cfg["model"])
2319
if cfg.load_model_from:

0 commit comments

Comments
 (0)