AssertionError: Duplicate registrations for type 'optimizer'


I’m working on Assignment #1, C4_W1.
When running, I get
“AssertionError: Duplicate registrations for type ‘optimizer’”

just from the first cell:
import csv

from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences

I’ve tried this in VS Code and PyCharm.
any ideas?


Hello @Ed_Sykes ,

You have posted this under Course 3 week 1 and in the text it is written C4W1.For the ambiguity, I went through both the notebooks.

The modules you mentioned are in C3W1. So considering this notebook of C3W1, it’s working fine from my side.

I would suggest you to run the cells again. If it still happens the same, then get the latest version.

To get the latest version, in your notebook, go to help at the right side
top corner and click on Get Latest Version.

Hope this helps.

With regards,
Nilosree Sengupta

Hello @Ed_Sykes

Did the issue get sorted out or are you still facing any issue?

Thank you


Mayank Ghogale


It is an issue with my Anaconda environment. I am still trying to resolve it.
I’ll post here once I have resolved it with the solution.

thank you,

Hello @Ed_Sykes ,

I see.
It’s just importing certain modules which are pre-installed properly on the Coursera Lab.So there shouldn’t be any issue for Coursera labs.
Let me know if it’s giving this error for Coursera lab.You can post screenshot here.

(And for local system, proper modules with compatible versions need to installed.When you are using multiple ide s and keep installing packages and running simultaneously, multiple versions may coexist in envs, if path is not set properly and the most updated one is not replacing the pre-existing ones but existing separately.So there may be an extra/dubplicate optimizer folder for keras.
So the ones not required, needs to be removed.

In such cases, if you cannot trace back, you may Uninstall fully and Reinstall again all the stuffs.

And just in case you are using Mac m1 or Mac silicon versions ,
tensorflow, keras installation doesn’t work in normal conventional way.It is bit complicated.You can use Google colab.)

With regards,
Nilosree Sengupta