In Programming Assignment: Transfer Learning with MobileNet I am getting: AttributeError: module ‘tensorflow.keras.layers’ has no attribute ‘RandomFlip’. Apparently
You have not placed your post in the correct forum area.
“Deep Learning Resources” is not intended for questions about specific assignments.
Please move your thread to the correct forum area for the course you are attending. You can do this using the “pencil” icon in the thread title.
For your question, you can use:
data_augmentation.add(RandomFlip('horizontal'))
1 Like
If you look at the “import” cell early in the notebook, here’s what you see (among other things):
from tensorflow.keras.preprocessing import image_dataset_from_directory
from tensorflow.keras.layers.experimental.preprocessing import RandomFlip, RandomRotation
So what does that tell you? Remember that we are doing very serious “OOP” (Object Oriented Programming) here, so you need to understand and respect the class or “inheritance” hierarchy.
RandomFlip
does not directly inherit fromtf.keras.layers
: there are two more subclasses in between. At least that is true for the version of TF being used in this assignment, which is 2.3.0. If you just google that, you may find a later version of TF in which that API is no longer considered “experimental”, but you have to deal with TF as you find it not as you wish it to be.- As Tom points out, you can just use it as
RandomFlip
, because it was imported that way.
PS: I moved the thread to DLS Course 4 by using the little “edit pencil” on the title.