umbertogriffo / focal-loss-keras

Binary and Categorical Focal loss implementation in Keras.
278 stars 67 forks source link

ValueError: Unknown loss function: categorical_focal_loss_fixed #30

Open dangmanhtruong1995 opened 2 years ago

dangmanhtruong1995 commented 2 years ago

Hi, I was using this library but I got this error when reloading (after successfully training).

File "/home/THEUSER/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/tensorflow/python/keras/saving/save.py", line 206, in load_model return hdf5_format.load_model_from_hdf5(filepath, custom_objects, File "/home/THEUSER/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 199, in load_model_from_hdf5 model.compile(**saving_utils.compile_args_from_training_config( File "/home/THEUSER/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/tensorflow/python/keras/saving/saving_utils.py", line 218, in compile_args_from_training_config loss = _deserialize_nested_config(losses.deserialize, loss_config) File "/home/THEUSER/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/tensorflow/python/keras/saving/saving_utils.py", line 259, in _deserialize_nested_config return deserialize_fn(config) File "/home/THEUSER/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/tensorflow/python/keras/losses.py", line 1854, in deserialize return deserialize_keras_object( File "/home/THEUSER/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 377, in deserialize_keras_object raise ValueError( ValueError: Unknown loss function: categorical_focal_loss_fixed

Do you know how to fix it ? Thanks a lot.

NIKHILDUGAR commented 1 year ago

Have you copied the losses.py 's functions to your code before calling it? If not then do try that.