07_food_vision_milestone_project_1 can't work in Tensorflow 2.5.0 #152
-
I am now currently following 07_food_vision_milestone_project_1_template and I can't run the feature extraction model. from tensorflow.keras import layers
from tensorflow.keras.layers.experimental import preprocessing
# Create base model
input_shape = (224, 224, 3)
base_model = tf.keras.applications.EfficientNetB0(include_top=False)
base_model.trainable = False # freeze base model layers
# Create Functional model
inputs = layers.Input(shape=input_shape, name="input_layer")
# Note: EfficientNetBX models have rescaling built-in but if your model didn't you could have a layer like below
# x = preprocessing.Rescaling(1./255)(x)
x = base_model(inputs, training=False) # set base_model to inference mode only
x = layers.GlobalAveragePooling2D(name="pooling_layer")(x)
x = layers.Dense(len(class_names))(x) # want one output neuron per class
# Separate activation of output layer so we can output float32 activations
outputs = layers.Activation("softmax", dtype=tf.float32, name="softmax_float32")(x)
model = tf.keras.Model(inputs, outputs)
# Compile the model
model.compile(loss="sparse_categorical_crossentropy", # Use sparse_categorical_crossentropy when labels are *not* one-hot
optimizer=tf.keras.optimizers.Adam(),
metrics=["accuracy"]) and the output error is
You can take a look at my current code here I have tried to fix by typecasting it but it didn't work. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hey @PhyoLinMg, It's a bug with the Weird that TensorFlow actually didn't look over this. Here a link to another discussion which reports the same issue : To know further about the issue |
Beta Was this translation helpful? Give feedback.
Hey @PhyoLinMg,
It's a bug with the
tensorflow 2.5.0
andEfficientNetBX
I downgraded the version totensorflow 2.4.1
and it works fine now.Weird that TensorFlow actually didn't look over this.
Here a link to another discussion which reports the same issue :
link
To know further about the issue
click here