Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【论文复现】clear_gradients() 报错 TypeError: 'NoneType' object is not iterable #26505

Closed
Ryan906k9 opened this issue Aug 20, 2020 · 2 comments

Comments

@Ryan906k9
Copy link

Traceback (most recent call last):
  File "main.py", line 94, in <module>
    main()
  File "main.py", line 86, in main
    gan.train()
  File "/home/aistudio/UGATIT.py", line 338, in train
    self.D_optim.clear_gradients()
  File "</opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/decorator.py:decorator-gen-59>", line 2, in clear_gradients
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in __impl__
    return wrapped_func(*args, **kwargs)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 216, in __impl__
    return func(*args, **kwargs)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/optimizer.py", line 791, in clear_gradients
    for p in self._parameter_list:
TypeError: 'NoneType' object is not iterable

请问这个报错可能是什么导致的?

@wangchaochaohu
Copy link
Contributor

如果调用clear_gradients只能在动态图下进行调用 这边把代码贴出来吗

@Ryan906k9
Copy link
Author

可能是缩进问题,已经修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants