blur-diffusion icon indicating copy to clipboard operation
blur-diffusion copied to clipboard

AttributeError: 'EMA' object has no attribute 'defaults'`

Open timerobin opened this issue 2 years ago • 6 comments

Hello , thank you for the code. I get a AttributeError when i want to train the model: Traceback (most recent call last): File "main.py", line 292, in <module> optimizer.zero_grad() File "/home/extradisk/miniconda3/envs/sr3/lib/python3.8/site-packages/torch/optim/optimizer.py", line 231, in zero_grad foreach = self.defaults.get('foreach', False) AttributeError: 'EMA' object has no attribute 'defaults' Could you help me with this bug ?

timerobin avatar Sep 21 '22 14:09 timerobin

Hi,

I wonder if you solved this problem because I have the same issue.

Best,

YunanWu2168 avatar Jan 31 '23 18:01 YunanWu2168

https://github.com/sangyun884/fast-ode/blob/master/EMA.py

Try this code instead, and let me know if it works.

sangyun884 avatar Jan 31 '23 23:01 sangyun884

File "E:\anaconda\envs\torch\lib\site-packages\torch\utils\data\sampler.py", line 225, in init raise ValueError("batch_size should be a positive integer value, " ValueError: batch_size should be a positive integer value, but got batch_size=0

GaoTianWL avatar Mar 06 '23 13:03 GaoTianWL

https://github.com/sangyun884/fast-ode/blob/master/EMA.py

Try this code instead, and let me know if it works.

Unfortunately with your code I've got AttributeError: 'EMA' object has no attribute '_optimizer_step_pre_hooks'. Did you mean: '_optimizer_step_code'?

DaddyWesker avatar Aug 25 '23 15:08 DaddyWesker

https://github.com/sangyun884/fast-ode/blob/master/EMA.py Try this code instead, and let me know if it works.

Unfortunately with your code I've got AttributeError: 'EMA' object has no attribute '_optimizer_step_pre_hooks'. Did you mean: '_optimizer_step_code'?

Any solution to this problem?

ArghyaPal avatar Sep 25 '23 09:09 ArghyaPal

Can you try PyTorch version of 1.11.0 or higher?

sangyun884 avatar Sep 25 '23 15:09 sangyun884