real-stanford / diffusion_policy

[RSS 2023] Diffusion Policy Visuomotor Policy Learning via Action Diffusion
https://diffusion-policy.cs.columbia.edu/
MIT License
1.09k stars 203 forks source link

Maybe ther is a bug in the code of diffusion_policy.model.diffusion.conditional_unet1d.py line 143: #86

Closed Davi-carto closed 1 month ago

Davi-carto commented 1 month ago

Maybe ther is a bug in the code of diffusion_policy.model.diffusion.conditional_unet1d.py line 143:

       up_modules = nn.ModuleList([])
       for ind, (dim_in, dim_out) in enumerate(reversed(in_out[1:])):
            is_last = ind >= (len(in_out) - 1)
            up_modules.append(nn.ModuleList([
                ConditionalResidualBlock1D(
                     dim_out*2, dim_in, cond_dim=cond_dim,
                     kernel_size=kernel_size, n_groups=n_groups,
                     cond_predict_scale=cond_predict_scale),
               ConditionalResidualBlock1D(
                      dim_in, dim_in, cond_dim=cond_dim,
                      kernel_size=kernel_size, n_groups=n_groups,
                      cond_predict_scale=cond_predict_scale),
               Upsample1d(dim_in) if not is_last else nn.Identity()
           ]))

suppose that in_out = [(6, 256), (256, 512), (512, 1024)] then run,python: for ind, (dim_in, dim_out) in enumerate(reversed(in_out[1:])): ... is_last = ind >= (len(in_out) - 1) ... print(ind, dim_in, dim_out) if not is_last else print("the last one") ... the result would be : 0 512 1024 1 256 512 so,is_last can never >= (len(in_out) - 1), and the up_models just has 1 Upsample1d block instead of 2. This will lead to that the sequence size of actions can not recover to be the size of horizon. Did I make some wrong understanding?I am really confused QAQ. Thanks for your attention!