def data_augmenter():
‘’’
Create a Sequential model composed of 2 layers
Returns:
tf.keras.Sequential
‘’’
### START CODE HERE
data_augmentation = tf.keras.Sequential([
tf.keras.layers.RandomFlip(“horizontal”),
tf.keras.layers.RandomRotation(0.2)
])
### END CODE HERE
Same Error for Me!
It seems to be an issue with the python version we are using.
In the latest TensorFlow version it is working fine…
But, no idea how to make this work in the Jupyter Notebooks.
Hey, @sandeep911 , @SairajNeelam found a solution, don’t use tf.keras.layers, look at the top RandomFlip and RandomRotation have already been imported, just use it as described above the graded code cell, and one more thing use tf.keras.models.Sequential() otherwise it will give ’ “‘module’ object is not callable. keras” error.
@Aditya_Singh has it right, the problem with the path is related to TF version. It was refactored between 2.3 and the latest, 2.6
I have multiple virtual environments on my desktop, so I got in the practice of adding these two lines of code in the notebook cell following all the imports. This way I’m always reminded what version is active in the environment:
print(tf.__version__)
print(tf.keras.__version__)
You might want to print out the Python version, too.
It’s not the Jupyter Notebook that causes the issue, it’s the version of TensorFlow on the cloud behind it. Actually a pretty common problem when dealing with the Python/TF/Keras/third party packages world where asynchronous refactoring and non- backward compatible changes are a fact of life. You can either configure a local env to match the versions run by Coursera or branch the source code to support different env configurations. Probably a good exercise to build a local virtual env and keep it synchronized with Coursera AWS (or Google Colab depending on the course and assignment). HTH
I am getting the same AttributeError and I’m not using tf.keras.layers. I am working with the code already in the cell plus the examples given in the tf.keras.Sequential documentation: