Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cannot import name 'binary_weighted_focal_crossentropy' from 'keras.backend'

im trying to import categorical_dqn

when i try the following

from tf_agents.agents.categorical_dqn import categorical_dqn_agent

i get

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ImportError: cannot import name 'binary_weighted_focal_crossentropy' from 'keras.backend' (C:\Users\tgmjack\anaconda3\lib\site-packages\keras\backend.py)

the advice i find around the internet Error importing binary_weighted_focal_crossentropy from keras backend: Cannot import name is to try importing this stuff first

from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.metrics import binary_focal_crossentropy

i end up with the exact same error caused by the second line of this suggestion however.

ImportError: cannot import name 'binary_weighted_focal_crossentropy' from 'keras.backend' (C:\Users\tgmjack\anaconda3\lib\site-packages\keras\backend.py)

####### bonus info ########

im running all this on anaconda

tensorflow version = 2.9.2

tf agents version = 0.5.0

keras version = 2.9.0

im trying to follow this tutorial = https://github.com/tensorflow/agents/blob/master/docs/tutorials/9_c51_tutorial.ipynb

>Solution :

I had a similar problem with tf_agents a few months ago. Doing this fixed it for me:

pip install tf-agents[reverb]

I have the following packages with their respective versions:

keras                         2.9.0
tensorflow                    2.9.2
tf-agents                     0.13.0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading