AttributeError: module 'tensorflow' has no attribute 'reset_default_graph'

This function is deprecated. Use tf.compat.v1.reset_default_graph() instead.

Update This is not the only function to be out of date. Check out this answer for release notes and a conversion script.


You normally import tensorflow by writing,

import tensorflow as tf

It's possible that you have named a file in your project tensorflow.py and the import statement is importing from this file.

Alternatively, you can try this,

from tensorflow.python.framework import ops
ops.reset_default_graph()

I have tried and successfully removed the attribute error

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D
from tensorflow.keras.layers import MaxPool2D
from tensorflow.keras.layers import Flatten
from tensorflow.keras.layers import Dense

classifier = Sequential()