When the index is a tuple

The rank a sweep can vouch for

To decide a tensor's rank, fit it at one rank after another and stop where something changes. Three things can be read off each rank's fits — the error, how nearly parallel the terms are, and whether fits from different starting points agree — and over six planted rank-three tensors at four noise levels they decide it 24, 12 and 15 times out of 24; the ratio of consecutive errors, which needs nothing, decides it 24 times. The error is right every time and has to be told the noise level. The collinearity is a coin toss. Agreement among starts is never wrong and, under noise, cannot decide on nine of the twenty-four — and the rank past the answer, where every decision is made, costs ten times the answer.

Worth reading first: An iteration that walks out of the set · A nearest point that is not there · A factorisation that is unique for once.

One term too many fitted a tensor built from three rank-one terms with four and found the fit perfect and wrong: a relative error of 101310^{-13}, with two of the four terms nearly parallel and cancelling. Nothing in the residual said so. The collinearity did, and the essay ended by proposing to make that a procedure — fit at rank one, two, three and upward, and stop when the collinearity jumps — and by listing what the procedure would need: a threshold on the jump, a policy for the starting points, since each fit starts at random and its collinearity varies with the start, and a price, because a sweep runs a fit per rank rather than one decomposition.

Stated as a procedure, the question becomes a measurement: over enough tensors, and with and without noise, which of the things a rank sweep can read decides the rank, how often, and at what cost. The answer is not the one the proposal expected, and the reason it is not says what the rank decision really is.

Three readings of every rank

The measurement uses six tensors, each six by six by six and built from three rank-one terms with Gaussian factors, and four noise levels: none, and relative Gaussian noise of 0.1%, 1% and 3%. Each tensor is fitted by alternating least squares at ranks two to five, from five starting points at each rank, with a cap of 1,500 sweeps a fit. Each rank’s five fits give three quantities.

The first is the best error any of them reached. The second is the collinearity of the best fit — the largest cosine between two of its terms’ columns, which the one-term-too-many essay found near one at rank four. The third is agreement among the starts: of the five fits, take those whose error is within a per cent of the best, and measure how well their terms match each other, by the congruence of two decompositions — the worst product of column cosines over the best matching of terms. A factorisation that is unique for once established why this should matter: a canonical decomposition of a tensor like these is unique when its rank is right, so fits that reach the answer from different starts should return the same terms, and past the right rank there is no unique answer for them to agree on.

The best error at each rank: six planted rank-three tensors, 1% noiseSix tensors built from three rank-one terms, six by six by six, with Gaussian noise of 1% noise added, each fitted by alternating least squares at ranks two to five from five starting points. The best error at each rank, per tensor. At rank three: 0.00896, 0.00877, 0.00888, 0.00885, 0.00858, 0.00884. At rank four: 0.00839, 0.00773, 0.00835, 0.00799, 0.0081, 0.00833.at rank threelowest across tensors0.0086highest across tensors0.009at rank fourlowest across tensors0.0077highest across tensors0.0084234510⁻²rank fittedbest relative errorsix planted tensorsdashed: the true rankeach line one tensor, fitted at ranks two to fivefive starting points at every rank
Fig. 1 The best error at each rank for the six tensors, at 1% noise. The dial changes the noise, from none to 3%.

The error is the familiar picture, and it is the one an iteration that walks out of the set warned about reading on its own: a small residual is not a finished fit. Without noise it falls from between 0.17 and 0.44 at rank two to 101410^{-14} at rank three and stays there. With 1% noise it falls to the noise level at rank three — between 0.858% and 0.896% for the six tensors — and then keeps falling slowly, to between 0.773% and 0.839% at rank four, because an extra term can always fit a little more of the noise. There is no rank at which a noisy error stops falling. There is a rank at which it reaches the noise, and a rule that knows the noise level can read it there.

The collinearity does not travel between tensors

How nearly parallel the best fit's terms are: six planted rank-three tensors, no noiseSix tensors built from three rank-one terms, six by six by six, each fitted by alternating least squares at ranks two to five from five starting points. How nearly parallel the best fit's terms are, per tensor. At rank three: 0.515, 0.960, 0.537, 0.648, 0.729, 0.652. At rank four: 0.999, 0.989, 0.947, 0.883, 0.975, 0.872.at rank threelowest across tensors0.52highest across tensors0.96at rank fourlowest across tensors0.87highest across tensors123450.40.60.81rank fittedlargest cosine between two termssix planted tensorsdashed: the true rankeach line one tensor, fitted at ranks two to fivefive starting points at every rank
Fig. 2 The largest cosine between two terms of each tensor’s best fit, at ranks two to five, without noise.

At rank four, one past the answer, the best fits’ collinearities are 0.999, 0.989, 0.947, 0.883, 0.975 and 0.872. At rank three they are 0.515, 0.960, 0.537, 0.648, 0.729 and 0.652. The one-term-too-many essay measured one tensor and saw the first row’s pattern — a jump from well below one to nearly one — and that tensor is in the set. The second tensor’s own terms are nearly parallel as planted: its correct rank-three fit has a cosine of 0.960, higher than two other tensors’ overfits. No threshold separates the two rows.

A rule that stops before the collinearity passes 0.95 names rank three on 12 of 24 sweeps across the four noise levels. It fails in both directions — naming rank two on tensors whose own terms are nearly parallel, and rank four or five on tensors whose extra term happens to pair less tightly — and moving the threshold trades one failure for the other. The collinearity is a property of the fit, and part of every fit’s collinearity is a property of the tensor — the same observation a rank that is not a property of the tensor made about rank itself, that what a fit returns depends on more than the object being fitted. Read against a tensor’s own earlier ranks it can say something; read against a fixed number it is a coin toss.

The starts agree at the answer and nowhere past it

How well the starts that reach the best error agree: six planted rank-three tensors, no noiseSix tensors built from three rank-one terms, six by six by six, each fitted by alternating least squares at ranks two to five from five starting points. How well the starts that reach the best error agree, per tensor. At rank three: 1.000, 1.000, 1.000, 1.000, 1.000, 1.000. At rank four: 0.056, one start only, 0.127, 0.097, 0.247, 0.119. On 2 tensor-rank pairs only one start reached the best error, so there was nothing to compare; they are drawn as open rings at the bottom.at rank threelowest across tensors1highest across tensors1at rank fourlowest across tensors0.056highest across tensors0.25234500.20.40.60.81rank fittedagreement among the starts that reach itsix planted tensorsdashed: the true rankeach line one tensor, fitted at ranks two to fivefive starting points at every rank
Fig. 3 For each tensor and rank without noise, how well the fits that reach the best error from different starts agree with each other. Open rings mark ranks where only one start reached it, leaving nothing to compare.

The third reading is the clean one. At rank three every tensor’s agreeing starts return the same terms to a congruence of 1.000, at every noise level. At rank four, where the starts that reach the best error can be compared, they disagree: 0.056, 0.127, 0.097, 0.247 and 0.119 on five tensors without noise — the four-term fits reach the same error with different terms, which is what a non-unique answer looks like. At rank two they agree too, because the best rank-two approximation of these tensors is also unique; agreement says a rank is not too large, and it is the step from agreement to disagreement that names the rank.

A rule built on that step — the largest rank whose starts agree, followed by one whose starts do not — is never wrong in the 24 sweeps. It names rank three on 15 of them. On the other 9 it cannot decide, and the reason is the most instructive thing in the measurement.

How well the starts that reach the best error agree: six planted rank-three tensors, 1% noiseSix tensors built from three rank-one terms, six by six by six, with Gaussian noise of 1% noise added, each fitted by alternating least squares at ranks two to five from five starting points. How well the starts that reach the best error agree, per tensor. At rank three: 1.000, 1.000, 1.000, 1.000, 1.000, 1.000. At rank four: one start only, one start only, one start only, one start only, 0.503, 0.083. On 9 tensor-rank pairs only one start reached the best error, so there was nothing to compare; they are drawn as open rings at the bottom.at rank threelowest across tensors1highest across tensors1at rank fourlowest across tensors0.083highest across tensors0.5234500.20.40.60.81rank fittedagreement among the starts that reach itsix planted tensorsdashed: the true rankeach line one tensor, fitted at ranks two to fivefive starting points at every rank
Fig. 4 The same agreement at 1% noise. At rank four only one start reaches the best error on four of the six tensors.

With noise, the fits one rank past the answer rarely reach the same error. At 1% noise, at rank four, only one start of five comes within a per cent of the best on four of the six tensors; on the other two the agreeing starts disagree about their terms, 0.503 and 0.083. A single agreeing start leaves nothing to compare, so the rule has no evidence that rank four is past the answer rather than a second unique fit. The starts do not agree on the error because they have not finished: every one of them runs to the cap. That is the subject of the essay that follows this one, and it is also where the rank sweep’s cost goes.

What the sweep costs, and where

What each rank costs: sweeps summed over six tensors and five startsFor each noise level, the alternating sweeps spent fitting ranks two to five, summed over six planted rank-three tensors and five starting points each, with a cap of 1,500 sweeps a fit. no noise: 1610, 5766, 4434, 11848; 0.1% noise: 1605, 4444, 45000, 45000; 1% noise: 1636, 4336, 45000, 45000; 3% noise: 1535, 4244, 45000, 45000.no noise: sweeps at rank 3, then 4rank three5766rank four44341% noise: sweeps at rank 3, then 4rank three4336rank four4.5·10⁴010,00020,00030,00040,000sweepsno noise0.1% noise1% noise3% noiserank 2rank 3rank 4rank 5bars, left to right: ranks two to fivea fit is capped at 1,500 sweeps
Fig. 5 Sweeps spent at each rank, summed over the six tensors and five starts, at each noise level; each fit is capped at 1,500 sweeps.

Without noise the sweep is cheap and even: 1,610 sweeps at rank two, 5,766 at rank three, 4,434 at rank four and 11,848 at rank five, summed over thirty fits a rank. The overfitted ranks converge — the extra term finds its cancelling partner and the error reaches rounding — and they cost about what the true rank does.

With noise the cost moves to one place. At 0.1%, 1% and 3% noise the true rank costs 4,444, 4,336 and 4,244 sweeps, and rank four costs 45,000 at all three — every fit to the cap. So does rank five. A rank sweep that goes one past the answer, which it has to in order to see that the answer was the answer, spends ten times as much at the rank it will reject as at the rank it will keep, and would spend more if the cap were higher.

That price has a precise shape. The information that decides the rank is at rank r + 1, not at rank r: the error only reaches the noise level there if the noise level is known, the collinearity only jumps there if the tensor’s own terms are not already parallel, and the starts only disagree there if they finish. Every rule reads the rank past the answer, and under noise that rank is the one that never finishes.

Three rules, scored

Three ways to decide the rank, over six tensors at four noise levelsFor each of 24 rank sweeps — six planted rank-three tensors at no noise and at 0.1%, 1% and 3% — how often each rule names rank three, names another rank, or cannot decide. The first rank whose error is at or below the noise level: 24 right, 0 wrong, and it has to be told the noise level. The first rank past which one more term improves the error by less than a fifth: 24 right, 0 wrong. The last rank before the best fit's terms are more than 0.95 parallel: 12 right, 12 wrong. The largest rank whose agreeing starts match, followed by one whose do not: 15 right, 0 wrong, 9 undecided because only one start reached the next rank's best error.right, of 24error at the noise level24next term gains under a fifth24collinearity below 0.9512starts agree, then do not15wrong, or cannot decideresidual0ratio0collinear12stable906121824rank sweepserror at the noise levelnext term gains under a fifthcollinearity below 0.95starts agree, then do notblue: rank three named; red: another rankgrey: the rule cannot decide
Fig. 6 For 24 rank sweeps — six tensors at four noise levels — how often each rule names rank three, names another rank, or cannot decide.

Put side by side: the error rule, stopping at the first rank whose error is at or below the noise level, names rank three 24 times out of 24 — and it needs the noise level, which is the one thing a user fitting real data often does not have. The collinearity rule, needing nothing, is right 12 times. The agreement rule, needing nothing but more starts, is right 15 times and wrong none, and undecided 9 times, every one of them because the fits one rank past the answer had not finished.

The comparison repeats the shape of the parameter-choice rules in the regularisation essays, where the rule told the noise level was the reliable one and the rules that inferred it had tails. Here the rule that infers the rank without the noise level is not unreliable. It is incomplete: it knows when it does not know, which the collinearity rule never does, and what it lacks is fits that finish. The test that is a deadline found that the quantities that separate a swamp from slow convergence separate them by when they fire rather than by a threshold, and the same holds here in a different form: the agreement rule is decided by whether the fits one rank past the answer converge at all.

A fourth reading, which needs no noise level

The error rule’s weakness is that it compares the error with a number from outside the fit. The fit itself says what that number is, if the error is read one rank at a time rather than against a threshold.

A term that fits structure in the tensor lowers the error by orders of magnitude. A term that can only fit noise lowers it by the share of the noise its parameters can absorb, and that share is a count. A rank-one term in a six by six by six tensor has 3 × 6 − 2 = 16 free parameters, the tensor has 216 entries, and a least-squares fit with k such terms leaves about 116k/216\sqrt{1 - 16k/216} of the noise behind it. The data count their dimensions, not the step’s found the same arithmetic in a regularised solve: past the dimensions the data carry, every added direction fits noise and nothing else, and the count of what is fitted is a count of parameters. For three terms the formula gives 0.882, for four 0.839, for five 0.793; measured over six tensors at three noise levels, the medians are 0.885, 0.833 and 0.781. The next essay draws the measurement.

So the ratio of consecutive errors is the reading. At the true rank the error falls by a factor of seven to twenty at 3% noise, by fifty at 0.1%, and by thirteen orders of magnitude without noise. One rank past it the error falls by (164/216)/(148/216)=0.951\sqrt{(1 - 64/216)/(1 - 48/216)} = 0.951 if the extra term takes exactly its share — measured, 0.881 to 0.954 across the eighteen noisy sweeps, all within a tenth of the prediction — and without noise it does not fall at all, since rounding is the floor at both ranks. A rule that stops where one more term improves the error by less than a fifth names rank three on all 24 sweeps, with and without noise, and is told nothing.

That makes it the rule the three readings above were reaching for, and it explains why each of them works as far as it does. The error against the noise level works because at the true rank the error is at about 0.88 of the noise level — the fit has absorbed its parameter share — and one rank past it is at 0.83, both close to the level and on the right side of it. The agreement rule works where the starts finish because the rank past the answer has a continuum of equally good fits, each absorbing the same share of noise with different terms. And the collinearity is unreliable because it measures something the error ratio does not need: the geometry of the terms, which depends on the tensor as well as on the rank.

The ratio rule has an edge of its own, and it is worth stating before anybody relies on it. It works because every term of these tensors is large against the noise, so the step at the true rank is a step of many digits. A term whose size is near the noise level lowers the error by about its parameter share too — the data cannot tell it from noise — and the ratio rule should stop before it — a prediction, since no tensor here has such a term. That would be the right answer, in the sense that such a term is not supported by the data, and it is not the planted rank. The same limit bounds the uniqueness of a factorisation in the presence of noise: a term the noise can hide is a term no rule can vouch for.

What a practitioner can take from it

A rank sweep should compare fits from several starts, not collinearities, and it should budget for the rank past the answer rather than for the answer. Five starts at the true rank are cheap and agree; five starts one rank past it are where the decision is made and where the time is spent, and without noise they converge and the decision is clean. With noise, a second, different reading is needed at that rank — the error against a noise level, if one can be estimated, or a longer run for the fits that must be compared — and the cap on sweeps becomes a parameter of the rank decision rather than of the fit. Or, cheapest of all, it should read the ratio of consecutive errors, which needs one start per rank that reaches its best error and no noise level at all.

What this does not settle

Six tensors of one size and one rank, with Gaussian factors, five starts a rank and a cap of 1,500 sweeps. A tensor whose true rank is larger, or whose terms are deliberately collinear, would move every number, and the agreement rule’s “agree” threshold of 0.9 congruence and “reach the best error” tolerance of one per cent are choices, not derived values.

The ratio rule’s threshold — stop when one more term gains less than a fifth — sits between a parameter share of about a twentieth and a structural gain of at least a factor of seven, and both ends of that gap move with the tensor. A larger tensor gives each term a smaller share of its entries, so the ratio past the answer creeps towards one and the rule gets safer; a small tensor, or many terms, gives each a larger share, and in a three by three by three tensor a term has seven free parameters among 27 entries, so a term past the answer would take about a quarter of the noise. No such case is measured.

The agreement rule counts one start as undecided. A rule that required a second start to finish before deciding — running the straggler longer — would convert some undecided cases, at the cost measured above; how many, and at what multiple of the cap, is not measured.

Still open: the agreement rule with fits that finish, and ranks the data cannot support

Giving the rank past the answer time to finish. The agreement rule is never wrong and is undecided exactly when the fits one rank past the answer have not converged. How long they must run before two of them reach the same error — and whether that time is a fixed multiple of the true rank’s, or grows with the noise — would turn the rule’s one gap into a cost that can be stated.

A rank the noise hides. Every tensor here has three terms well above the noise. A term whose size is comparable to the noise level is a term the data cannot resolve, and whether the agreement rule then names the smaller rank — the honest answer — or undecides is the measurement that would say how the rule behaves at the edge of what the data supports.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

Alternating least-squaresBorder-rankCP decompositionDegeneracyIll-posed problemStopping criterionSwampTensor rankUniqueness