How to perform median filtering in multi-label prediction
I don't think median filtering is a good approach for this problem. It is definitely used as a smoothing mechanism in single pitch tracking, but I don't think that's necessarily the best way to go. For example, when tracking single pitches, a dynamic programming algorithm can be really powerful. At each frame of audio you have pitch candidates with some strength to them. Dynamic programming lets you find an optimal path between those candidates such that you penalize big jumps in pitch (like a whole octave) while promoting pitch candidates with high weights.

As far as I'm aware, though, this doesn't scale well to multiple pitches. I have seen authors use this algorithm to track just two pitches in the case of two concurrent speakers.

This is a really hard problem to solve in general, and I don't think just filtering that binary matrix will be sufficient -- I think you want some sort of weights associated with each pitch candidate, and to make decisions with those weights. You can also take time into account -- if you detect two notes that are an octave (or other integer multiple) apart, and follow the same relative pitch trajectory and onset at exactly the same time, they are probably the same note. You could also try using the weights to inhibit octave errors -- for example, if you detect a note, but there's significant energy at half its frequency, you might be looking at an octave error.