Tensorflow ValueError: Unexpected result of `train_function` (Empty logs). Please use `Model.compile(…, run_eagerly=True)
Question:
I’m trying to make a face detection model with CNN. I used codes that I made for number detection. When I use number images, program work. But, when I use my face images, I get an error that is:
Unexpected result of train_function
(Empty logs). Please use Model.compile(..., run_eagerly=True)
, or tf.config.run_functions_eagerly(True)
for more information of where went wrong, or file a issue/bug to tf.keras
.
Answers:
Your input images have a shape of (32,32,3)
whil you first conv2D layer sets the inputshape to (32,32,1)
. Most likely your numbers have only 1 channel since they are grayscale, while you face images have 3 color channels.
change:
model.add(tf.keras.layers.Conv2D(input_shape = (32,32,1), filters = 8, kernel_size = (5,5),activation = "relu", padding = "same" ))
to
model.add(tf.keras.layers.Conv2D(input_shape = (32,32,3), filters = 8, kernel_size = (5,5),activation = "relu", padding = "same" ))
Also ensure that you declared initialised all the parameters in the compile functions , i had the exact error when i forgot to initialise batch_size in the fit function after the compile function.
I’m trying to make a face detection model with CNN. I used codes that I made for number detection. When I use number images, program work. But, when I use my face images, I get an error that is:
Unexpected result of train_function
(Empty logs). Please use Model.compile(..., run_eagerly=True)
, or tf.config.run_functions_eagerly(True)
for more information of where went wrong, or file a issue/bug to tf.keras
.
Your input images have a shape of (32,32,3)
whil you first conv2D layer sets the inputshape to (32,32,1)
. Most likely your numbers have only 1 channel since they are grayscale, while you face images have 3 color channels.
change:
model.add(tf.keras.layers.Conv2D(input_shape = (32,32,1), filters = 8, kernel_size = (5,5),activation = "relu", padding = "same" ))
to
model.add(tf.keras.layers.Conv2D(input_shape = (32,32,3), filters = 8, kernel_size = (5,5),activation = "relu", padding = "same" ))
Also ensure that you declared initialised all the parameters in the compile functions , i had the exact error when i forgot to initialise batch_size in the fit function after the compile function.