# Geting batch size in keras custom loss

I am implementing a custom loss in keras, for example, a sum:

def custom_loss(y_true, y_pred):
K.sum(y_true, y_pred)


Now, I want to normalize it by the batch size. Is it possible, to retrieve the batch size from y_true or y_pred?

I would say this highly depends on how you have your code set up. What type of model are you creating? Are you not setting batch-size as a global parameter? Can you not just use that? Also, assuming y_true is a numpy matrix, can you just use: y_true.shape[dimension_representing_batch_size] as a means of getting the size?