Figure A-25. Code to define a custom metric and use that for the model
Figure A-24. The code definition of categorical accuracy as seen in the Keras
GitHub page
Of course, there are many more metrics that are available on the Keras
documentation, and you can even define
custom metrics. To do that, just simply define
a function that takes in y_true and y_pred, and call that function name in your metrics,
as shown in Figure
A-25
.
In this example, you simply rewrite the binary accuracy metric in several lines and
return the score. You can actually condense this function to just one line like in the actual
implementation seen above, but this is just an example to showcase a custom metric.
Do'stlaringiz bilan baham: |