act-plus-plus icon indicating copy to clipboard operation
act-plus-plus copied to clipboard

Diffusion Policy

Open zxfever opened this issue 1 year ago • 11 comments

I train the model with the --policy_class Diffusion parameters,but the error occurred:

Traceback (most recent call last):
  File "imitate_episodes.py", line 682, in <module>
    main(vars(parser.parse_args()))
  File "imitate_episodes.py", line 187, in main
    best_ckpt_info = train_bc(train_dataloader, val_dataloader, config)
  File "imitate_episodes.py", line 562, in train_bc
    policy = make_policy(policy_class, policy_config)
  File "imitate_episodes.py", line 203, in make_policy
    policy = DiffusionPolicy(policy_config)
  File "/home/lenovo/code_ws_python/act-plus-plus/policy.py", line 72, in __init__
    ema = EMAModel(model=nets, power=self.ema_power)
TypeError: __init__() missing 1 required positional argument: 'parameters'

Can you provide some help?

zxfever avatar Jun 26 '24 07:06 zxfever

Hello, When I changed the line as below

ema = EMAModel(parameters=nets, power=self.ema_power)

it started to train. However, during the inference I get another error. I will ask a question about it later.

barsm42 avatar Jul 08 '24 00:07 barsm42

@barsm42 have you found a solution to this? I am searching for one myself, I encountered the same problem

QueirosJustin avatar Jul 13 '24 14:07 QueirosJustin

@barsm42 have you found a solution to this? I am searching for one myself, I encountered the same problem

Not yet, unfortunately.

barsm42 avatar Jul 16 '24 05:07 barsm42

@barsm42 I found it, it works but the parameters need to be set differently. try this:

python3 imitate_episodes.py
--task_name aloha_mobile_wipe_wine
--ckpt_dir /scr/tonyzhao/train_logs/wipe_wine_diffusion_seed0
--policy_class Diffusion --chunk_size 32
--batch_size 32 --lr 1e-4 --seed 0
--num_steps 100000 --eval_every 100000 --validate_every 10000 --save_every 10000

The problem is that if it's evaluating the policy for every 500, 2000 or another small stepnumber, then diffusion policy isn't working well and the simulation crashed through invalid physics state. Therefore, it needs to be higher. I achieved the best result for the command above, if you use eval_every 6000 and onscreen_render you can directly see the improvements after 6000 steps instead of 100 000 steps

QueirosJustin avatar Jul 16 '24 05:07 QueirosJustin

@QueirosJustin Thank you for your reply.

In my code, I dont have --eval_every 100000 --validate_every 10000 --save_every 10000 args.

imitate_episodes.py gave error for those arguments.

barsm42 avatar Jul 16 '24 05:07 barsm42

can you post a screenshot? Those arguments are definitely part of the imitate_episode.py script, look at this section "def main(args): set_seed(1) # command line parameters is_eval = args['eval'] ckpt_dir = args['ckpt_dir'] policy_class = args['policy_class'] onscreen_render = args['onscreen_render'] task_name = args['task_name'] batch_size_train = args['batch_size'] batch_size_val = args['batch_size'] num_steps = args['num_steps'] eval_every = args['eval_every'] validate_every = args['validate_every'] save_every = args['save_every'] resume_ckpt_path = args['resume_ckpt_path']"

QueirosJustin avatar Jul 16 '24 05:07 QueirosJustin

I don't have these four arguments. I searched with Ctrl+F in the script, there are not any variables as eval_every and the rest.

eval_every = args['eval_every'] validate_every = args['validate_every'] save_every = args['save_every'] resume_ckpt_path = args['resume_ckpt_path']"

barsm42 avatar Jul 16 '24 05:07 barsm42

@QueirosJustin, What should I do for that arguments?

barsm42 avatar Jul 24 '24 01:07 barsm42

Hi guys, I fixed it by using the EMAModel class from Diffusion Policy, it will help you to solve this issue!

huyquoctrinh avatar Dec 24 '24 20:12 huyquoctrinh

check the diffuser version, the correct version should be : pip install diffusers==0.11.1

junhui1997 avatar Jan 06 '25 08:01 junhui1997

hello, Does anyone have any recommendations for training settings? At approximately how many steps does the Diffusion Policy converge?

return-sleep avatar Feb 02 '25 15:02 return-sleep