본문 바로가기
DeepLearning Framework & Coding/De-bugging

cannot import name 'Adam' from 'keras.optimizers'

by 노마드공학자 2021. 9. 6.

Tensorflow, keras를 사용할때 갑자기 keras.optimizer를 import할수 없다는 경우 해결법

 

[문제코드]

from keras.optimizers import Adam

 

[해결코드]

"from tensorflow.keras.optimizers import Adam"로 바꾸자!!

 

 

from tensorflow.keras.optimizers import Adam # - Works

from tensorflow.keras.optimizers import adam # - Does not work

from keras.optimizers import Adam # - Does not work

from keras.optimizers import adam # - Does not work

 

[참고]

https://stackoverflow.com/questions/62707558/importerror-cannot-import-name-adam-from-keras-optimizers

 

ImportError: cannot import name 'adam' from 'keras.optimizers'

I am trying to import Keras but I get the following error: ImportError: cannot import name 'adam' from 'keras.optimizers' (/usr/local/lib/python3.8/dist-packages/keras/optimizers/__init__.py) The ...

stackoverflow.com

 

댓글