AI Wiki中文/EN

Multi-task learning: sharing reduces noise and adds bias

多任务学习

Solve two coupled regressions exactly and derive when sharing reduces error or causes negative transfer.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Two tasks can lend each other evidence

Two sensors estimate similar quantities, but each has few noisy readings. Fitting them separately ignores possible similarity. Forcing them to have exactly the same mean may erase a real difference. Multi-task learning offers intermediate choices by sharing parameters, representations or constraints while retaining task-specific outputs.

Caruana’s Multitask Learning, Sections 1.1–1.3, studies learning related tasks together, including shared neural representations. It is a family of approaches, not one optimizer. Pan and Yang’s survey, Section 2.1, contrasts simultaneous task learning with a source-to-target transfer emphasis. The terminology overlaps; an experiment should specify which tasks are optimized and which results matter.

Our example fits two scalar regression means with a coupling penalty. It makes the benefit and harm of sharing calculable without a neural network. Read bias and variance and regularization first.

Share softly through a penalty

Let m₁,m₂ be observed task means and a,b their fitted estimates. Minimize:

J(a,b)=12(a−m1)2+12(b−m2)2+λ2(a−b)2,λ≥0.J(a,b)=\frac12(a-m_1)^2+\frac12(b-m_2)^2+\frac\lambda2(a-b)^2, \qquad\lambda\geq0.

Each task contributes an equally weighted mean-squared objective; expanding mean squared error over its observations changes only an additive constant. Equal task weight is a chosen policy, even when sample counts differ. Larger λ discourages different task means. λ=0 gives separate fits, while λ growing without bound approaches one pooled mean under this weighting.

The stationary equations are(1+λ)a−λb=m₁ and(1+λ)b−λa=m₂. Adding and subtracting them yields:

c=11+2λ,mˉ=m1+m22,a=mˉ+c2(m1−m2),b=mˉ−c2(m1−m2).c=\frac1{1+2\lambda},\qquad \bar m=\frac{m_1+m_2}{2},\qquad a=\bar m+\frac c2(m_1-m_2),\quad b=\bar m-\frac c2(m_1-m_2).

The Hessian has eigenvalues 1 and 1+2λ, both positive. Thus this solution is the unique minimum. The common mean is unchanged; only the difference shrinks. For m₁=1,m₂=3 and λ=1, the fitted values are 5/3 and 7/3.

This particular two-mean penalty is our original teaching model, not an implementation of Caruana’s neural experiments. Hard parameter sharing, soft penalties and shared latent features impose different constraints and should not be treated as equivalent algorithms.

When does shrinking help on average?

Assume the two sample means are independent, unbiased estimates of true means θ₁,θ₂, each with variance v. Let Δ=θ₁−θ₂. The average estimation MSE across the two fitted tasks is:

R(λ)=12E[(a−θ1)2+(b−θ2)2]=v2(1+c2)+(1−c)2Δ24.R(\lambda)=\frac12\mathbb E[(a-\theta_1)^2+(b-\theta_2)^2] =\frac v2(1+c^2)+\frac{(1-c)^2\Delta^2}{4}.

To derive it, express each estimate as a weighted sum of m₁ and m₂. Its variance is v(1+c²)/2; its bias has magnitude(1−c)|Δ|/2. Add variance and squared bias. The variance decreases with stronger coupling, while the bias grows if the true means differ.

At v=1 and λ=1, equal true means give risk 5/9 instead of the separate-fit risk 1. True means 0 and 4 give risk 7/3, worse than 1. Sharing trades reduced noise for distortion of real differences. This is negative transfer in a specified estimator and task pair, not evidence that every shared model must fail on those tasks.

Enumerate the noise rather than guess from one run

The complete Python 3.12 program computes exact rational fits. For its risk experiment, each task supplies one observation equal to its true mean plus independent noise−1 or+1, each equally likely. The four joint noise outcomes are all enumerated.

from fractions import Fraction as F
from itertools import product


def coupled_fit(tasks, coupling=1):
    tasks=[list(values) for values in tasks]
    if len(tasks)!=2 or any(not 1<=len(values)<=32 for values in tasks):
        raise ValueError('exactly two tasks, each with one to32 observations required')
    if any(type(v) not in (int,F) or abs(v)>1000000 for values in tasks for v in values):
        raise ValueError('bounded rational observations required')
    if type(coupling) not in (int,F) or not 0<=coupling<=1000:
        raise ValueError('nonnegative rational coupling at most1000 required')
    means=[sum(map(F,values),F(0))/len(values) for values in tasks]
    center=sum(means)/2;difference=(means[0]-means[1])/(1+2*F(coupling))
    return center+difference/2,center-difference/2


def exact_risk(truth, coupling):
    truth=list(truth)
    if len(truth)!=2 or any(type(v) not in (int,F) or abs(v)>100 for v in truth):
        raise ValueError('two bounded rational true means required')
    risk=F(0)
    for noise in product((-1,1),repeat=2):
        estimates=coupled_fit([[truth[i]+noise[i]] for i in range(2)],coupling)
        risk+=sum((estimate-F(theta))**2 for estimate,theta in zip(estimates,truth))/8
    return risk


if __name__=='__main__':
    print('separate fits for means1 and3:',*[str(v) for v in coupled_fit([[0,2],[2,4]],0)])
    print('coupled fits at lambda1:',*[str(v) for v in coupled_fit([[0,2],[2,4]],1)])
    for truth in [(2,2),(0,4)]:
        print('true task means:',truth)
        for coupling in (0,1):print('lambda:',coupling,'exact average estimation MSE:',exact_risk(truth,coupling))

Output:

separate fits for means1 and3: 1 3
coupled fits at lambda1: 5/3 7/3
true task means: (2, 2)
lambda: 0 exact average estimation MSE: 1
lambda: 1 exact average estimation MSE: 5/9
true task means: (0, 4)
lambda: 0 exact average estimation MSE: 1
lambda: 1 exact average estimation MSE: 7/3

This experiment has unbiased observation means and v=1, exactly matching the formula’s assumptions. The true means enter only the synthetic risk experiment and its error calculation, never the fit rule. “Average estimation MSE” refers to estimating the two means; predicting a fresh noisy reading would add its irreducible noise variance.

Fitting requires one pass through both tasks, O(n₁+n₂) rational operations, and constant additional state after the input lists are materialized. The closed-form calculation avoids an iterative stopping rule. The four-outcome experiment is finite and exact; it is not a real sensor benchmark.

Task relatedness must be tested

Tasks with similar names may require incompatible features. A dominant task can control shared gradients, and differing output scales can make equal loss weights misleading. Conversely, some tasks have missing labels or different data sources, requiring explicit sampling and masking rules. Sharing an architecture does not settle these choices.

This model assumes comparable scalar outputs and equal penalty geometry. With unequal sample variances, optimal pooling should account for precision; the displayed equal-variance risk formula no longer applies unchanged. A learned shared representation is more flexible than shrinking all task means together, but must still be evaluated for negative transfer.

Compare separate-task, fully shared and partially shared baselines using the same data access and evaluation budget. Report every task’s result, not only an aggregate that can hide a harmed task. Choose coupling or task weights on validation data, retaining an untouched test set.

Which part of the estimate changed?

  1. What are the fits for means 1 and 3 with λ=1?

Answer 1: 5/3 and 7/3; their average remains 2.

  1. Which direction is left unchanged by the penalty?

Answer 2: The common-mean direction. The task difference is multiplied by 1/(1+2λ).

  1. Why does coupling hurt when true means are 0 and 4 in the risk example?

Answer 3: The squared bias from shrinking a real difference exceeds the variance reduction, giving 7/3 rather than 1.

  1. Is the displayed risk a noisy-observation prediction error?

Answer 4: No. It is mean-estimation MSE; fresh observation noise adds another term.

Separate sharing mechanisms in the comparison

Project: sweep λ and Δ in the exact noise experiment, verify the analytic risk, and plot where coupling beats separate fitting. Then change one task’s noise variance and derive a precision-aware alternative before claiming it is better.

For a neural extension, compare separate networks with a shared feature extractor and task-specific heads. Inspect per-task validation curves and gradient interactions. Transfer learning studies reuse for a target task; multi-label learning studies multiple binary labels per example. These settings can use multi-task techniques while retaining their own data and evaluation definitions.

Make a prediction, then check

What remains unchanged in the two-mean coupling model?

Choose one answer

Learning objectives

  • Solve a two-task coupling objective and explain what shrinks.
  • Derive the variance and bias tradeoff under explicit assumptions.
  • Evaluate sharing per task against independent baselines.

Prerequisites & connections

Explore related knowledge →

References

  1. Multitask Learning
    Rich Caruana · 1997
  2. A Survey on Transfer Learning — accepted author manuscript
    Sinno Jialin Pan; Qiang Yang

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-06 · Codex single-agent authored technical review: cited primary-source scope, explicit assumptions, original calculations and counterexamples, runnable tests and bilingual review; not independent human or second-agent review.

  • Single-agent authored technical review: bounded primary-source locations, assumptions, original derivations, exact/literal references and matching bilingual equations/examples/exercises. Not independent human or second-agent review.
  • Four focused CPython3.12.4 tests passed per chapter. Exact rational metrics, four-outcome task risks, source/frozen/gradient fits and shifted-domain risks are checked against literal or analytic references. No external runtime dependencies.
  • Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
  • Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.

Source locations checked:

  • Multitask Learning · Author-hosted35-page paper, Sections1.1–1.3 and overview: related-task signals, shared representation and multiple algorithm families. Two-mean penalty and exact risk are original, not replicas of the neural experiments.
  • A Survey on Transfer Learning — accepted author manuscript · Accepted manuscript Section2.1, physicalpage2: simultaneous multi-task learning versus source/target asymmetry, and Section6 pointer to negative transfer. No final publication date inferred from2009 in URL.

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.