TL;DR
Permutation invariant training, or PIT, is a loss for models that output several sources at once, such as the voices in a recording of several people talking. The network has no built-in idea of which output slot should hold which speaker, so PIT compares every way of matching slots to the true sources and keeps the best one. The result is a loss that does not care about the order of the outputs.
Where you'll see it: in speech separation systems that split a mixed recording into one track per speaker, in models that track several moving objects, and in later separation networks such as Conv-TasNet.
Intuition
A panel with two chairs
Picture a radio panel with two guests and a host who records both answers. Afterwards you have two recordings, but nobody labelled which chair each guest sat in. To grade the host's separation, you must first decide which recording belongs to which guest. The natural rule is to try both seatings, measure how close each one is to the truth, and keep the seating that fits best.
A neural network that separates voices has the same problem. Its outputs are slots, and at the start of training slot 1 has no reason to hold speaker A rather than speaker B. If the loss simply compares slot 1 with speaker A's true voice, the network is told to do the wrong thing whenever its slots are assigned the other way round. The training signal becomes noise.
PIT removes the problem by letting the loss choose the matching itself. It asks: which assignment of outputs to sources makes the total error smallest? Then it trains the network to reduce that error.
flowchart LR A[Mixture of voices] --> B[Network] B --> C[Output slots 1 to S] C --> D[Try every matching of slots to true sources] D --> E[Keep the matching with the smallest total error] E --> F[Train on that error]
Using the mixture's spectrogram as input is common, so the network sees the sound as a picture of frequencies over time. The matching logic is independent of that choice. It only needs a per-source error.
The math
The ambiguity
Let there be sources, with true signals , and let the network produce estimates . Nothing in the network ties slot to a particular source. If the training loss is written as , it fixes one matching in advance. Any run that happens to put speaker B in slot 1 is penalised for doing the right thing. The matching the network learns is therefore arbitrary, and it can change between examples.
The permutation-invariant loss
Let be the set of all permutations of , and let be a loss for one source, such as the Mean Squared Error between two signals. PIT defines
Here is one permutation, a rule that sends target to output slot . The inner sum is the total error for that matching, and the minimum picks the matching with the smallest total. Because the minimum runs over all orderings of the outputs, the value of does not change when the outputs are reordered. That is the sense in which the loss is permutation invariant.
Utterance-level versus frame-level
A recording is a sequence of frames . The simplest version chooses the best matching separately in each frame:
This is cheap and it always gives the lowest total error. It fails for speech. A frame-level choice can match output 1 to speaker A in one frame and to speaker B in the next, so the separated tracks swap speakers in the middle of a sentence. The utterance-level version uses one matching for the whole recording:
The matching is decided once per utterance, so each output track keeps one speaker. This is the form that makes separation usable.
Gradients
A minimum over a finite set is locally one of its branches. Once the best matching is found, the gradient flows only through the outputs in :
The other matchings do not contribute to the update. Ordinary Stochastic Gradient Descent with Backpropagation therefore trains the network without any change to the optimiser.
How many matchings
There are permutations (see Counting Principles), which grows fast:
| Sources | Permutations |
|---|---|
| 2 | 2 |
| 3 | 6 |
| 4 | 24 |
| 5 | 120 |
| 10 | 3,628,800 |
For the two- and three-speaker cases that are common in practice, trying every matching is cheap. It is not cheap for large , and the tradeoffs section returns to this.
Worked examples
Two sources have true values . The network outputs . Use squared error for .
- Identity matching ( sends source 1 to slot 1 and source 2 to slot 2): .
- Swapped matching (source 1 to slot 2, source 2 to slot 1): .
- The minimum is , from the swapped matching. The loss is .
- The gradient flows only through the swapped pairs. Slot 1 is pushed toward 1, and slot 2 toward 2.
Interpretation: the network did separate the two values correctly, but in the opposite order. A fixed loss would have punished it with 2.42. PIT scores it at 0.02, which is what a correct separation deserves.
A two-speaker recording has three frames. The total error for each matching in each frame is:
| Frame | Identity | Swapped |
|---|---|---|
| 1 | 0.5 | 0.9 |
| 2 | 0.8 | 0.3 |
| 3 | 0.4 | 0.6 |
- Frame-level PIT takes the best matching in each frame: frame 1 gives 0.5 (identity), frame 2 gives 0.3 (swapped), frame 3 gives 0.4 (identity). The total is .
- Utterance-level PIT sums each matching across frames first. Identity gives and swapped gives . The minimum is 1.7, from identity.
- The frame-level total, 1.2, is lower, but it is not a consistent answer. It would train output 1 to hold speaker A in frames 1 and 3 and speaker B in frame 2.
- The utterance-level total, 1.7, is higher but consistent. Output 1 holds one speaker throughout.
Interpretation: the frame-level loss looks better because it is allowed to cheat. Each frame reaches its own best score by changing who each output represents, and the separated tracks become unusable. Utterance-level PIT gives up a little error to keep the tracks coherent.
Take four sources, so .
- The number of matchings is .
- For utterance-level PIT, each matching needs a total error summed over all the frames and all four sources. That is 24 totals to compare, each a sum of 4 per-source errors per frame.
- Each total is a sum of terms for an utterance of frames, so one minimum costs about term evaluations.
- Doubling the number of sources from 2 to 4 multiplies the matchings from 2 to 24, a factor of 12, while the number of sources only doubled.
Interpretation: the cost grows like rather than . This is manageable for a few speakers and becomes the main constraint as grows.
A segment of a meeting has three speakers, so there are matchings. Suppose the summed utterance-level errors, in arbitrary units, for the six matchings are:
| Matching (output slots for speakers A, B, C) | Summed error |
|---|---|
| (1, 2, 3) | 4.2 |
| (1, 3, 2) | 3.9 |
| (2, 1, 3) | 5.0 |
| (2, 3, 1) | 4.6 |
| (3, 1, 2) | 4.4 |
| (3, 2, 1) | 4.1 |
- The minimum is 3.9, from the matching (1, 3, 2). The loss for the segment is .
- Slot 1 is trained against speaker A, slot 3 against speaker B and slot 2 against speaker C. The gradient flows through those three pairs only.
- The segment is the unit of decision. Every frame of the segment uses the same matching, so slot 1 keeps speaker A from the first second to the last.
The numbers are illustrative, not measured. Interpretation: the winning matching is not the identity, and nothing in the network had to be told that. The loss found it, and the same procedure works on every segment in the training set.
Tradeoffs and failure modes
PIT is simple and general, and it works with any network that outputs one estimate per source. The costs come from the matching step itself.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Frame-level matching on speech | Output tracks swap speakers mid-utterance | Utterance-level PIT, one matching per recording |
| Many sources | matchings are too many to enumerate | Hungarian matching on the matrix of pairwise errors (see the Hungarian algorithm below) |
| Fewer sources in some recordings than in others | A fixed forces the missing sources to be padded with silence | Pad with silent targets, or use a count-aware matching |
| Evaluation with fixed output order | A good separation looks bad because the tracks are labelled in the wrong order | Score the estimates under their best matching, as in training |
| Speakers at very different levels | Unnormalised squared error lets the loud source dominate the matching | A scale-invariant per-source loss such as the negative SI-SNR |
The Hungarian algorithm gives a useful shortcut. Build an matrix whose entry is the error of output against source , summed over frames for the utterance-level case. The minimum over matchings of is exactly the assignment problem, and the Hungarian algorithm solves it in time that grows as rather than . It returns the same minimum as PIT, so this is a faster route to the same loss, not an approximation. Detection transformers use the same idea to match predicted boxes to ground-truth objects.
PIT also cannot tell the network which outputs should be silent when a source is absent, and it does not impose any order across time. Both gaps are usually closed by the design around the loss rather than by the loss itself.
History
Before deep learning, separating a mixture of voices was usually done with signal-processing assumptions, such as the sources being statistically independent. Those methods worked for a few clean cases and failed when voices overlapped or when the recording had noise. The problem that people now call the cocktail party problem, picking one voice out of many at a party, was a central example.
Supervised approaches using neural networks made progress in 2016. Deep clustering assigned each time-frequency point an embedding, and then grouped the points into speakers with a clustering step. That avoided the output-order problem, but it needed a separate clustering stage and was awkward to train end to end.
In 2017 Dong Yu, Morten Kolbæk, Zheng-Hua Tan and Jesper Jensen introduced permutation invariant training. It removed the clustering step by letting the loss pick the matching. Kolbæk and colleagues then described the utterance-level form, which fixed the speaker-switching problem and made speaker-independent separation work for recordings of two speakers. Later systems such as Conv-TasNet built on this objective.
PIT caught on because it solved the ambiguity with a few lines of code. It needed no hand-designed matching, no extra stage and no change to the training procedure, and it turned a problem that looked like it needed structure into one that standard gradient descent could solve.
Recap
A model that outputs several sources has no fixed order for its outputs, so a loss that compares slot with source gives a random training signal. PIT takes the minimum of the total error over all matchings, , which makes the loss invariant to output order. Matching once per utterance keeps each track on one speaker. The cost grows as , which the Hungarian algorithm reduces to a cubic-time assignment with the same minimum. The objective is the basis of later separation systems such as Conv-TasNet.
Check yourself
QuestionRecall: what ambiguity does permutation invariant training remove, and how?Show answer
The outputs of a multi-source network have no fixed correspondence to the true sources, so a loss that matches slot to source penalises correct separations in the wrong order. PIT removes the ambiguity by taking the minimum of the total error over all matchings of outputs to sources, so the loss scores each separation by its best matching.
QuestionComputation: how many matchings does PIT compare for four sources, and how many summed error totals does utterance-level PIT compare for one utterance?Show answer
There are matchings. Utterance-level PIT sums the error of each matching across all frames, so it compares 24 totals, one per matching. The number of totals does not depend on the number of frames; the frames are summed inside each total.
QuestionWhy: why can frame-level matching give a lower loss yet produce unusable separated tracks?Show answer
Each frame picks its own best matching, so the output slots can swap speakers from one frame to the next. The loss is lower because every frame gets its best score, but the output tracks no longer each contain one speaker. Utterance-level matching forces one consistent assignment for the whole recording, which costs a little in loss and keeps the tracks coherent.
QuestionApplied: you want to separate eight sources. What is the difference between enumerating matchings and using the Hungarian algorithm, and which would you use?Show answer
Enumerating matchings means checking permutations, each a sum of eight terms. The Hungarian algorithm works on the matrix of pairwise summed errors and returns the minimum over the same matchings in time that grows as the cube of the number of sources. Because the two give the same minimum for a loss that sums per-source errors, I would use the Hungarian algorithm, and I would check that the per-source loss is a sum over sources so the equivalence holds.
Sources
- Yu, Kolbæk, Tan, Jensen, Permutation Invariant Training of Deep Models for Speaker-Independent Multi-talker Speech Separation (2017): https://arxiv.org/abs/1607.00325
- Kolbæk, Yu, Tan, Jensen, Multi-talker Speech Separation with Utterance-level Permutation Invariant Training of Deep Recurrent Neural Networks (2017): https://arxiv.org/abs/1703.06284
- Hungarian algorithm (Wikipedia)
- Cocktail party effect (Wikipedia)