Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.57k
stars
11.69k
forks
source link
Training balloon.py ValueError: Expected a symbolic Tensors or a callable for the loss value. Please wrap your loss computation in a zero argument `lambda`. #2906
# Add L2 Regularization
# Skip gamma and beta weights of batch normalization layers.
reg_losses = [keras.regularizers.l2(self.config.WEIGHT_DECAY)(w) / tf.cast(tf.size(w), tf.float32)
for w in self.keras_model.trainable_weights
if 'gamma' not in w.name and 'beta' not in w.name]
print(tf.add_n(reg_losses))
self.keras_model.add_loss(tf.add_n(reg_losses))
Error occurred as below
File ".\Mask_RCNN\mrcnn\model.py", line 2107, in co
mpile
self.keras_model.add_loss(tf.add_n(reg_losses))
File ".\anaconda3\envs\MaskRCNN\lib\site-packages\keras\engine\base_layer.py
", line 1488, in add_loss
"Expected a symbolic Tensors or a callable for the loss value. "
ValueError: Expected a symbolic Tensors or a callable for the loss value. Please wrap your
loss computation in a zero argument `lambda`.
python==3.7.15 tensorflow==2.10.0 keras==2.10.0
".\Mask_RCNN\mrcnn\model.py"
Error occurred as below
Please anyone helps me