'Getting keras compiled model loss function
Is there any way to get the compiled model loss/metrics functions from the model object?
I need this to access the loss function from within a callback, where I have access to self.model, but I can't find a way to access the compiled loss.
Solution 1:[1]
In tensorflow 2.4, model.compiled_loss._losses returns the name of the loss function.
Solution 2:[2]
If you want to view the loss function use model.loss
Using model.compiled_loss._losses will return a LossFunctionWrapper object which you can call, but cannot get any other information on.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | arod19 |
