ck37/coral-ordinal

OrdinalCrossEntropy should not require `num_classes`; can be inferred from `y_pred`

gmgeorg opened this issue · 0 comments

Thanks for a great package.

One slight inconvenience is that OrdinalCrossEntropy() has a required (!) argument to specify num_classes, which makes the loss function non-standard compared to other standard keras losses (e.g., crosscategory_entropy does not require to specify num_classes either). This however is not required to pass at __init__(), but can be inferred from y_pred.shape[1] . Any particular reason to not implement it this way?

I can add a PR to add this if needed (also can be backwards compatible by leaving num_classes: Optional[int] = None).