Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Errror using custom loss #653

Open
max37400 opened this issue Apr 14, 2023 · 1 comment
Open

Errror using custom loss #653

max37400 opened this issue Apr 14, 2023 · 1 comment
Labels
bug Something isn't working ml-framework ML Framework support requirements Finding requirements and dependencies needed to properly serialize objects serialization Dumping and loading Python objects

Comments

@max37400
Copy link

max37400 commented Apr 14, 2023

Hello!

I've tried to use custom loss function like this:

def rmlse(y_true, y_pred):
    return mean_squared_logarithmic_error(y_true, y_pred)**0.5

optimizer = keras.optimizers.Adam(learning_rate=0.05)
model.compile(optimizer=optimizer, loss=rmlse, metrics=['mean_absolute_error'])

The model was built successfully, but when we tried to upload that model with mlem, the provided error rises:

Unexpected error: Unknown loss function: 'rmlse'. Please ensure you are using a keras.utils.custom_object_scope and that this object is included in the scope. See 
https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.

How can I use the custom loss functions?
Thanks!

@aguschin aguschin added bug Something isn't working ml-framework ML Framework support requirements Finding requirements and dependencies needed to properly serialize objects labels Apr 19, 2023
@aguschin
Copy link
Contributor

I assume this happens when trying to load the model.
Looks like MLEM does not pin down this requirement when recursively going over the model at saving, I guess we need to see if this is fixable as a special case + add some option to make MLEM investigate reqs deeper (get more broad list of reqs, but at the same time pin reqs like this down).

@aguschin aguschin added the serialization Dumping and loading Python objects label Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working ml-framework ML Framework support requirements Finding requirements and dependencies needed to properly serialize objects serialization Dumping and loading Python objects
Projects
None yet
Development

No branches or pull requests

2 participants