Majid Al-RaimiFrom sensitivity curves to per-layer ratios

COE 592Lecture 4.2Part 03

From sensitivity curves to per-layer ratios

Pick an accuracy threshold, read off each layer's pruning rate where its curve crosses it, and see why this heuristic ignores the interaction between layers.

Concepts
3
Slides
18-23
Reading
18 min
Understood
0/3 concepts

Why this part matters

Part 02 ended with a wall of six curves and no numbers. This part is the step that converts that chart into the six per-layer ratios you actually type into a pruning script, and it is the exact place where an exam will hand you a small accuracy table, a threshold and a parameter count per layer, and ask for the per-layer rates and the overall rate.

It is also the baseline that every automated method in the rest of the lecture is judged against. AMC and NetAdapt exist because the threshold read-off has a specific, nameable flaw, so for the research project you need to be able to run this heuristic, defend it as a cheap starting point, and say precisely why it falls short. One horizontal line, six crossings, one weighted sum, one honest caveat. That is the whole part.

By the end you can

  1. Read a sensitivity chart and classify layers as sensitive or redundant from the slope of their curves.
  2. Apply the threshold rule to read off a pruning rate for every layer, including layers that never cross T.
  3. Compute the overall pruning rate as a parameter-weighted average and adjust T until it meets a target.
  4. Explain in one sentence why the result is sub-optimal, using the words single-layer sweep and interaction.
  5. Connect the limits of the heuristic to the motivation for automated pruning in the next two parts.

Put your finger on the 80% column of the VGG-11 chart and read straight down. The green L1 curve is still at about 92% accuracy. The blue L0 curve has already dropped to about 71%. Same network, same dataset, same pruning ratio, and the two layers are twenty points apart. That gap is the entire reason per-layer pruning ratios exist, and it is what the six curves are there to expose.

Recall what each curve is. Sensitivity analysis prunes one layer L_i alone at ratios r in {0, 0.1, ..., 0.9}, measures the accuracy at each ratio with every other layer left dense, then moves on to the next layer and repeats. The result is one accuracy versus ratio line per layer. Every line starts at the same place, the dense accuracy of about 93% on CIFAR-10, so the starting point carries no information at all. What differs is the slope: how soon and how steeply each line bends down as r grows. That slope is the layer's sensitivity.

LayerAt 70% prunedAt 80% prunedAt 90% prunedVerdict
L083.5%71%32%Most sensitive: bends first, falls off a cliff
L193%92%85%Most redundant: flat almost to the end
L291.5%89.5%79%Redundant: still about 79% at 90%
L391.5%85.5%51%Moderate: bends late, drops hard at 90%
L490.5%77%39%Sensitive past 70%
L592%90%82%Redundant: about 82% at 90%
Six curves at a glance (accuracy read from the slide chart, VGG-11 on CIFAR-10)

The rule that falls out of the table is simple. A curve that stays flat as r grows belongs to a redundant layer: most of its weights can go with no visible cost, so it should be pruned hard. A curve that bends early belongs to a sensitive layer: its weights are doing work that nothing else in the network can absorb, so it should be pruned gently. The slide summarizes it as "some layers are less sensitive to pruning" (L1, the flattest) and "some layers are more sensitive to pruning" (L0, the steepest), and the whole point of drawing all six on one axis is that you can rank them by eye.

Why the first layer is the fragile one

L0 being the most sensitive is not a quirk of this run. Han et al. (2015), the paper the chart's method comes from, report the same pattern on AlexNet: "The first convolutional layer, which interacts with the input image directly, is most sensitive to pruning. We suspect this sensitivity is due to the input layer having only 3 channels and thus less redundancy than the other convolutional layers" (section 5, Figure 6). Their Figure 6 also shows convolutional layers as a group being more sensitive than fully connected layers, which is the same story at coarser resolution: the layers with the fewest weights per unit of work have the least slack. A 3 x 3 kernel over three input channels has 27 weights per filter; removing 80% of them leaves five, and five numbers cannot describe an edge detector.

Recall

Which VGG-11 layer in the chart is most sensitive, and what physical reason does Han et al. give?

L0, the first conv layer. It interacts with the input image directly, and the input has only three channels, so the layer has little redundancy to spare.

Quick check

On the VGG-11 chart, which layer tolerates 90 percent pruning best, and what does that say about it?

Now draw one dashed horizontal line across the chart just under 80% accuracy, where the slide puts it (measured against the gridlines it sits at about 79%). Walk along the blue L0 curve from the left. It sits above the line through 60%, is still above it at 70% (about 83.5%), and has dropped to 71% by 80%. Somewhere between those two grid points it crossed the line, at roughly 73% pruning. That crossing is L0's pruning rate. Do the same for the orange L3 (about 82%) and the steep red L4, whose 80% point sits just under the line: strict interpolation puts the crossing at about 78.5%, and the slide rounds its drawn guide up to 80%. L1, the flat red L2 and L5 never reach the line inside the sweep, so they get the largest tested rate, 90%, which is where the slide draws its last vertical guide.

The threshold line rises to the slide's level, then a crossing marker and a vertical guide light up for each layer in the order they cross. The replica's crossings land within about a point and a half of the slide's guides

Pruning rates read off at T of about 79 to 80 percent (from the dashed guides on the slide)

L0
about 73%: crosses T between the 70% and 80% points
L1
90% or beyond: still about 85% accuracy at the last swept ratio
L2
90% or beyond: about 79% accuracy at 90%, on the line
L3
about 82%: crosses just past the 80% point
L4
about 78% by interpolation; the slide rounds its drawn guide up to 80%
L5
90% or beyond: about 82% accuracy at 90%

That is the whole mechanism, and it deserves to be stated as an algorithm rather than a picture, because the exam version comes as a table, not a chart. Choose an accuracy threshold T. For each layer, the pruning ratio is the largest swept ratio whose accuracy is still at or above T. Layers whose curves never dip below T inside the sweep get the maximum swept ratio.

ri=max{r{0,0.1,,0.9}:AccriT}r_i = \max\left\{\, r \in \{0, 0.1, \dots, 0.9\} : \mathrm{Acc}^{\,i}_{r} \ge T \,\right\}
Table form: the largest swept ratio at or above T. On a chart, interpolate the crossing between the last grid point at or above T and the first below it

The read-off table above and the worked example below follow the slide's drawn guides, which use the chart form and interpolate between grid points. By the strict table form L0 and L4 would snap to 70% and L3 to 80%, and exact interpolation puts L4 at about 78.5%, so the slide's 80% guide for L4 is a rounding of its own chart. The formula is the exam rule; the guides are how the slide applies it by eye.

From six rates to one overall rate

The slide bullet reads "pick a degradation threshold T such that the overall pruning rate is desired", and the word overall hides a calculation students routinely get wrong. The overall rate is not the average of the six numbers. It is the fraction of all weights removed, so each layer's rate is weighted by how many weights that layer has. A 90% rate on a layer with 2.36 million weights removes far more than a 73% rate on a layer with 1,728.

R=iriNiiNi,compression=iNii(1ri)Ni=11RR = \frac{\sum_i r_i N_i}{\sum_i N_i}, \qquad \text{compression} = \frac{\sum_i N_i}{\sum_i (1 - r_i)\, N_i} = \frac{1}{1 - R}
Overall pruning rate as a parameter-weighted average, and the compression factor it implies

T is the one knob. If R comes out below the target, lower T: every curve now runs further right before it crosses, so every r_i grows or stays pinned at the maximum swept ratio, and R never falls. If the pruned network turns out too inaccurate, raise T and no rate can grow. The loop is: pick T, read off six rates, compute R, compare with the target, move T, repeat. It converges in a handful of iterations because R is monotone in T.

Worked example

What the slide's T buys on VGG-11

  1. Assign illustrative weight counts

    The slide does not say which six layers L0 to L5 are, so take the first six 3 x 3 conv layers of VGG configuration A (Simonyan and Zisserman, Table 1) with biases ignored: 3 x 64 x 9 = 1,728, 64 x 128 x 9 = 73,728, 128 x 256 x 9 = 294,912, 256 x 256 x 9 = 589,824, 256 x 512 x 9 = 1,179,648, 512 x 512 x 9 = 2,359,296. Total 4,499,136. These counts are illustrative; the read-off rule does not depend on them, but R does.
  2. Multiply each rate by its count

    Rates in layer order are 0.73, 0.90, 0.90, 0.82, 0.80, 0.90, taken from the slide's drawn guides rather than the strict grid rule: exact interpolation puts L4 at 0.785, and the 0.80 here is the slide's rounding of that guide. So 1,728 x 0.73 + 73,728 x 0.90 + 294,912 x 0.90 + 589,824 x 0.82 + 1,179,648 x 0.80 + 2,359,296 x 0.90 is about 3,883,778 weights pruned.
  3. Divide by the total

    R = 3,883,778 / 4,499,136 = 86.3%. About 615,358 weights remain.
  4. Weighted versus unweighted

    QuantityValueWhy it differs
    Unweighted mean of the six rates84.2%Treats the 1,728-weight L0 like the 2.36M-weight L5
    Parameter-weighted rate R86.3%The big late layers are pruned at 80 to 90%, so R is higher
    Weights remaining615,358 of 4,499,136About one in seven survives
    Compression factor7.3x1 / (1 - 0.863)

The simulator below runs this loop on curves digitized from the slide, so at its default T of 79% the interpolated crossings land within about a point and a half of the slide's guides (L4 reads 78.5% against the drawn 80%) and R reads 86.0% against the worked example's 86.3%. Drag T and watch all six vertical guides move at once; switch between snapping to the 10% grid and interpolating between grid points; and read R, the unweighted mean and the compression factor as they update. Try T at 90 first, then 70, and note which direction R moves.

SimulatorThreshold read-off: one line, six pruning rates
79.0% accuracy floor
304458728610010%20%30%40%50%60%70%80%90%pruning rate per layer, VGG-11 on CIFAR-10 (digitized from the slide)accuracy (%)T = 79%L0L1L2L3L4L5
Per-layer pruning rate read off at the current threshold, with illustrative weight counts
LayerShape (illustrative)RateAccuracy thereWeightsPruned
L03 x 64 x 3 x 373.6%79.0%1,7281,272
L164 x 128 x 3 x 390.0%85.0%73,72866,355
L2128 x 256 x 3 x 390.0%79.0%294,912265,421
L3256 x 256 x 3 x 381.9%79.0%589,824482,972
L4256 x 512 x 3 x 378.5%79.0%1,179,648926,242
L5512 x 512 x 3 x 390.0%82.0%2,359,2962,123,366
Overall rate R85.9%sum(r_i N_i) / sum(N_i)
Unweighted mean84.0%mean of the six rates
Weights left633,508of 4,499,136
Compression7.1x1 / (1 - R)

Drag T down and every vertical guide slides right at once: one knob moves all six rates. Drag it up and the guides retreat, so a higher T prunes less. The six curves are digitized from the slide chart, and the default T of 79% is where the slide draws its dashed line, a hair under the 80 mark. The weight counts are illustrative: the first six 3 x 3 conv layers of VGG configuration A with biases ignored, since the slide does not say which layers L0 to L5 are. Snap mode returns the last grid point still at or above T; interpolate mode places the crossing between grid points, which is what the dashed guides on the slide do.

Same L0 curve twice. Raising T from 70 to 86 percent pulls the crossing from about 80 to about 64 percent, and the pruned span under the axis shrinks

The exam version: a table instead of a chart

On paper you will get an accuracy table for two or three layers, a threshold and a weight count per layer. The procedure is identical. Read each row until the accuracy falls below T, take the last ratio that was still at or above T, weight by the counts, and add.

Layerr = 50%r = 60%r = 70%r = 80%r = 90%
A (100,000 weights)90%84%70%52%30%
B (400,000 weights)95%93%91%86%75%
C (500,000 weights)95%95%94%93%90%
Exam-style table: accuracy after pruning one layer alone, threshold T = 90 percent

Worked example

Three layers, T = 90 percent

  1. Read each row

    A is at 90% at r = 50 and 84% at 60, so r_A = 50%. B is at 91% at 70 and 86% at 80, so r_B = 70%. C is still at 90% at the last ratio, so r_C = 90%.
  2. Weight by the counts

    100,000 x 0.5 + 400,000 x 0.7 + 500,000 x 0.9 = 50,000 + 280,000 + 450,000 = 780,000.
  3. Divide by the total

    R = 780,000 / 1,000,000 = 78%. 220,000 weights remain, a compression of about 4.5x. The unweighted mean would have been 70%, which is wrong.
  4. One sentence on optimality

    The rates come from single-layer sweeps, so the accuracy of pruning A, B and C together is never measured and is usually below T. The next concept explains why.

Recall

State the rule that turns one layer's sensitivity curve into a pruning rate.

The rate is where the curve crosses T: on a table, the largest swept ratio still at or above T; on a chart, the interpolated crossing between grid points. Layers that never cross T inside the sweep get the maximum swept ratio.

Recall

Your overall pruning rate comes out below target. Do you raise or lower T, and why?

Lower T. A lower accuracy floor lets every curve run further to the right before crossing, so each per-layer rate grows or stays at the maximum swept ratio, and the weighted overall rate never falls.

Recall

Three layers with 100k, 400k and 500k weights read off at 50, 70 and 90 percent. What is the overall rate?

(50k + 280k + 450k) / 1M = 78%, not the unweighted 70%.

Quick check

You raise the accuracy threshold T from 80 percent to 88 percent on the sensitivity chart. What happens to the per-layer pruning rates read off the curves?

Quick check

Layer A has 200,000 weights and crosses T at 60 percent, B has 300,000 and crosses at 80 percent, C has 500,000 and crosses at 90 percent. Overall pruning rate?

Take two of the rates you just read off. L0 pruned to 73% on its own costs about 14 points (93 down to the line at 79). L4 pruned to 80% on its own costs about 16 points. Now prune both at once. L4 was trained on features that flow through a dense L0. Its tolerance to losing 80% of its weights was measured with those features intact, and that condition no longer holds. The network now sees both perturbations at the same time, and the combined drop is usually larger than either single-layer drop, and the chart contains no measurement of it.

ExperimentAccuracyDrop
L0 pruned to 73%, nothing else touched93 to about 79about 14 points, measured on the chart
L4 pruned to 80%, nothing else touched93 to about 77about 16 points, measured on the chart
Both pruned at oncenot on any curveusually more than either single drop, never measured by the sweep
Alone versus together, VGG-11 at the read-off rates
Each single-layer bar drops to about T, as its curve promised. The combined bar drops further, into a gap no sweep ever measured. The third bar's level is illustrative

The slide asks "is this optimal?" and answers itself: "maybe not. We do not consider the interaction between layers." The next slide of the source deck puts it even more directly, "sensitivity analysis ignores the interaction between layers, sub-optimal". The reason is built into the procedure. Each curve is a one-dimensional slice of accuracy along one layer's axis, taken with every other layer frozen dense. The read-off then treats those axes as independent, as if you could add up six separate tolerances and get the tolerance of the whole. Layers are not independent. That is the Layer interaction the heuristic leaves out, and it is why T is only a proxy for the accuracy you will actually get, not a guarantee.

Sweep each layer alone
6 layers x 9 ratios = 54 runs

Every other layer stays dense while one layer is pruned.

six curves
Choose T, read six rates
one horizontal line

Each rate assumes the other five layers are still dense.

interaction ignored
Prune all six at once
a network no sweep measured

Losses compound. Fine-tuning recovers some of the gap.

Three stages of the heuristic. Interaction is never measured because the sweep and the final prune are different experiments

Why the heuristic ignores interactions on purpose

The omission is a cost decision, not an oversight. The sweep needs (layers) x (ratios) evaluations, 6 x 9 = 54 here, each a forward pass over the validation set. Measuring every joint setting would need 9^6 = 531,441 evaluations for six layers, and real networks have dozens of layers. The AMC paper says exactly this about hand-crafted rules: "as the layers in deep neural networks are not independent, these rule-based pruning policies are non-optimal, and doesn't transfer from one model to another model", and "the design space has exponential complexity, which is infeasible to be solved by greedy, rule-based methods" (He et al., 2018, section 1). The heuristic trades optimality for a search that finishes in an afternoon.

Two things keep it usable in practice. First, Fine-tuning after pruning (part 06) recovers a large share of the compounded loss, so the read-off does not have to be exact, only in the right region. Second, it is the starting point that the automated methods improve on rather than throw away. NetAdapt removes filters from one layer per iteration, re-measures accuracy after a short fine-tune, and keeps the best proposal, so interactions get folded in one step at a time (Yang et al., 2018). AMC goes further and learns the whole per-layer assignment as one policy, rewarded on the accuracy of the jointly pruned network (He et al., 2018). Both are Automated pruning, and both exist because the single-layer sweep leaves accuracy on the table.

Recall

In one sentence, why is the threshold read-off sub-optimal?

Each curve was measured with only that layer pruned, so the accuracy loss of pruning all layers together, which compounds through layer interactions, is never measured.

Recall

How many evaluations does the sweep cost for six layers and nine ratios, and how many would a full joint search cost?

6 x 9 = 54 for the sweep, against 9^6 = 531,441 joint settings. The exponential cost is why the heuristic ignores interactions and why parts 04 and 05 use learning and greedy measurement instead.

Quick check

Why does pruning every layer at its threshold-read rate usually lose more accuracy than T predicts?

Recap

If you remember nothing else

  • Sensitivity is the slope of a layer's accuracy versus ratio curve. L0 (first conv, 3-channel input) is the most sensitive, L1 the most redundant.
  • The threshold rule: r_i is where the curve crosses T. In table form it is the largest swept ratio at or above T; in chart form it is the interpolated crossing between grid points. Layers that never cross T get the maximum swept ratio.
  • With T at about 79 to 80 percent (the slide's dashed line) the guides read off roughly 73, 90+, 90+, 82, 80 and 90+ percent for L0 to L5.
  • The overall rate is parameter-weighted, not the mean of the six rates. With illustrative VGG-11 counts it is about 86 percent (7.3x) against an unweighted 84 percent.
  • Higher T keeps more weights, lower T prunes more. Tune T until the overall rate hits the target.
  • Every curve is a single-layer experiment, so simultaneous pruning compounds losses the chart never measured. T is a proxy and the assignment is sub-optimal.
  • Han et al. used this heuristic successfully (9x on AlexNet, 13x on VGG-16 with iterative retraining). AMC and NetAdapt exist because a better joint assignment exists.

Sources