Can keras.utils.Sequence return a triple?

I have a model where the inputs are X,Y,M. All of them are matrices. My custom loss function needs access to the Mask matrix so that I can do something like tf.square(y_true - y_pred*mask). All of my batches are generated by a class that inherits from keras.utils.Sequence.

All of the examples I have seen show the getitem method for the Sequence class returning x,y.
I need to return x,y,m. Is this legal? I’m trying to debug a problem and I need to understand if this basic assumption about the Sequence was valid?

Hi @Bob_Zigon,

Sorry for the delay in response.
Yes, returning multiple outputs from __getitem__ in a Keras Sequence class is valid but standard keras training expects two.We have to make sure that __getitem__ method returns three items: x_batch, y_batch, and mask_batch(in your case) and need to modify the loss function to handle the triple input. Here’s a sample implementation gist of above for your reference.

Hope this helps.Thank You.