I am trying to implement multiple instance learning, as described in this paper 1. Each batch (user in my case) still has multiple instances, though the number of instances may be different across users (which means the batch size is not fixed). The gradients would be updated after every person, but after multiple instances, so the learning should be stable.
For some minimal sample data, assume the dataset is somewhat like this:
X = [[2,3], [1,1], [4,3], [6,2]]
y = [0, 1, 0, 1]
subjects = [0, 0, 1, 2]

then I want X to be batched based on subjects:
batch_0 = [[2,3], [1,1]]
batch_1 = [[4,3]]
batch_2 = [[6,2]]

In my actual dataset, there are about 15 instances per subject, so the batch size will not be too small.
Thank you!