Passing meta data from data Loader to custom loss function

I am trying to pass meta-data, for the reference labels that i will be using in a custom loss function. I am accessing the input (to model), labels, meta-data through the data loader. however I can’t seem to figure out a way to pass the meta-data to the loss function while fetching it from the data loader, as it keeps giving me an error saying the y_true labels don’t match with that of the expected model outputs. Does anyone have any idea how to pass meta-data from data loader into the loss function?

Hi @paras_Joshi, Welcome to the Forum!

To include metadata in your loss function, you can try wrapping the model and loss logic together, using a custom Model subclass. This lets you override train_step() and manually pass metadata into the loss.