Tensorflow: AlreadyExistsError Another metric with the same name already exists

Viewed 404

Code:

import tensorflow as tf
import time

mnist = tf.keras.datasets.mnist

Error:

Exception has occurred: AlreadyExistsError
Another metric with the same name already exists.
  File "/Users/sean/Documents/GitHub/VIQ-Intern-Projects/test.py", line 4, in <module>
    mnist = tf.keras.datasets.mnist

I have tried to uninstall keras. Then another error happens. Keras was not found.

1 Answers

This error arises due to mismatch of TensorFlow and keras version available in your system. Make sure you use same version of Tensorflow and Keras to execute this code.

Check the existing version of Tensorflow and keras using below code:

import tensorflow
print(tensorflow.__version__)

import keras
print(keras.__version__)

If you find any difference in versions, install the same version of keras as tensorflow to fix this issue.

Suppose, you have tensorflow_version = 2.6.0, then install keras in same version using below code:

!pip install keras==2.6.0 

or

#you can import keras from tensorflow while running your code.
from tensorflow import keras 
print(keras.__version__)

Try executing the above code again.
Let us know if issue still persists.

Related