keras-cv icon indicating copy to clipboard operation
keras-cv copied to clipboard

f_scores & sparse_f_scores

Open markub3327 opened this issue 3 years ago • 7 comments

Hello,

@bhack @LukeWood

this is solution of #393. Please check it and I'll make a test for SparseFBetaScore.

Thanks.

markub3327 avatar May 11 '22 18:05 markub3327

What is the status of this? We are closing another request on TF https://github.com/tensorflow/tensorflow/issues/56358

bhack avatar Jun 17 '22 23:06 bhack

What is the status of this? We are closing another request on TF tensorflow/tensorflow#56358

I've been prioritizing other issues over this for a bit, also deciding how components that support multiple label types:

i.e. classification, object detection, and image segmentation should be structured

I will do a pass on this now.

LukeWood avatar Jun 18 '22 00:06 LukeWood

Why is it required to have f_1/2_score if we can get them with a general f_beta_score? It doesn't seem to need various beta=n versions and thus will reduce implemented cost and clean API.

innat avatar Jun 18 '22 13:06 innat

@innat

It's easier for the newbie users to understand the CV.

For example, F1 is common metrics described in wide range of tutorials.

markub3327 avatar Jun 18 '22 14:06 markub3327

Why is it required to have f_1/2_score if we can get them with a general f_beta_score? It doesn't seem to need various beta=n versions and thus will reduce implemented cost and clean API.

It could be similar to passing single RGB values or Colormapping: https://github.com/keras-team/keras-cv/pull/433

bhack avatar Jun 21 '22 00:06 bhack

Hi @bhack @LukeWood, all tests are passed. You can merge it. Thanks!

markub3327 avatar Aug 05 '22 14:08 markub3327

Do we have a review here?

bhack avatar Oct 11 '22 18:10 bhack

@markub3327 Could you please test your implementation with this https://github.com/keras-team/tf-keras/issues/251 ? (As this implementation is quite similar to tfa.f1 score.)

innat avatar Feb 25 '23 22:02 innat

@innat I have available PC with only one GPU.

markub3327 avatar Feb 26 '23 20:02 markub3327

You can still try with mirror or single strategy scope. Or, use kaggle env, it provides multi gpu for free and tf 2.11.

innat avatar Feb 27 '23 01:02 innat

@innat @bhack

All is working for me. Here is notebook: https://www.kaggle.com/code/martinkubovksk/notebooke5641a9136

Here is the result:

Number of devices: 2

Epoch 1/5 2/2 [==============================] - 15s 608ms/step - loss: 0.8687 - f1_score: 0.6667 - val_loss: 0.9360 - val_f1_score: 0.6667 Epoch 2/5 2/2 [==============================] - 0s 177ms/step - loss: 0.8406 - f1_score: 0.6667 - val_loss: 0.9011 - val_f1_score: 0.6667 Epoch 3/5 2/2 [==============================] - 0s 173ms/step - loss: 0.8150 - f1_score: 0.6667 - val_loss: 0.8684 - val_f1_score: 0.6667 Epoch 4/5 2/2 [==============================] - 0s 173ms/step - loss: 0.7930 - f1_score: 0.6667 - val_loss: 0.8386 - val_f1_score: 0.6667 Epoch 5/5 2/2 [==============================] - 0s 165ms/step - loss: 0.7698 - f1_score: 0.6667 - val_loss: 0.8110 - val_f1_score: 0.6667 [8]: <keras.callbacks.History at 0x7fe44859cfd0>

markub3327 avatar Mar 01 '23 22:03 markub3327

These metrics are a bit more generic than just "CV" and as such probably belong in Keras core if they are valuable. Closing for now, but perhaps @fchollet would think these are a good fit for core Keras? If there is a strong user need I think we should re-open this PR to introduce F-scores in core, but for now lets close until such a need arises.

LukeWood avatar Apr 26 '23 21:04 LukeWood