Because we all need some wholesome content sometimes, meet Benji.
What I learned today: you can't use if-conditionals in a Keras custom loss function. I managed to come with a solution...
All the operations in the custom loss function need to be vectorised, so an if-conditional breaks it and throws an exception. The solution is to create Boolean vectors corresponding to each condition, turn their types into float (must be float), multiply each Boolean by the corresponding loss function and sum.
Example: