VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

How AI Works | Local Reparameterization Trick — Activation Noise, Gradient Variance and Gaussian Weights

The local reparameterization trick changes where randomness enters a variational neural-network calculation. Instead of drawing one random weight matrix and sharing it across every example in a minibatch, a layer computes each example’s preactivation mean and variance and samples local Gaussian noise at that preactivation. Under the specified independent Gaussian weight assumptions, each example has the same marginal preactivation distribution, while the training examples’ sampled noise can be independent. This can reduce stochastic-gradient variance.

The useful distinction is not simply whether dropout or a Gaussian is used. Global weight sampling creates correlated random effects across a minibatch, which may prevent averaging more examples from reducing all sources of gradient noise. Local noise can remove that shared random component for a sum of per-example losses. The transformation does not establish that a model is calibrated, that every Bayesian prior is valid, or that local samples reproduce the full joint output distribution of one shared weight draw.

This article develops the mechanism from the 2015 NeurIPS research by Kingma, Salimans and Welling, checks a two-input numerical layer, calculates covariance and minibatch-variance denominators, explains where the equivalence stops and distinguishes a later critique of log-uniform variational dropout priors. The worked numerical cases are constructed mathematical illustrations, not reported training measurements or deployed model results.

Contents and learning routes

The source of the gradient noise is a global weight draw · Define the mean-field Gaussian model before doing arithmetic · A global Gaussian draw is itself a reparameterization · Translate a weight distribution into local activation moments · Hand-check a layer with two uncertain weights · A single global weight draw couples the two examples · Preserving each example does not preserve arbitrary cross-example statistics

An invented noise draw shows what is actually sampled · Why shared covariance changes how a batch average behaves · Worked variance comparison with a declared covariance · Sampling activations changes the array sizes and computational work · The shape of local noise must match the preactivation layout · Where nonlinearities can and cannot be moved · Weight sharing across spatial locations introduces another dependency

Local sampling changes a data-term estimator, not the global posterior · A hand-checked evidence-bound scaling exercise · How Gaussian dropout connects to weight uncertainty · Learned dropout rates raise extra modelling questions · The log-uniform prior interpretation has substantive limitations · Reduced gradient noise is not the same as predictive calibration · Find the earliest layer where equivalence fails

Stable variance parameters and small values deserve attention · Changed-context transfer: add a third uncertain weight · A rigorous comparison separates estimator quality from model quality · When to use the trick and when not to add it

Frequently asked questions · Research sources · Related eduKate articles.

The source of the gradient noise is a global weight draw

Consider a neural layer whose weights are not represented by one fixed vector during training. Instead, each weight is assigned a probability distribution intended to approximate uncertainty about parameters. One ordinary Monte Carlo implementation draws a complete weight matrix and uses it to evaluate a minibatch of observations. It then differentiates a sampled objective with respect to the distribution’s parameters.

That strategy can be valid as an estimator, but the entire minibatch sees the same random weight perturbation. Two different examples can therefore experience related changes in their outputs for reasons unrelated to their data. Averaging more examples reduces independent per-example variation but need not eliminate the common variation induced by the one shared weight draw.

The original local reparameterization work asked how to make the stochastic gradient estimator more efficient without discarding a variational objective. Its method moves randomness from shared global weights to local preactivation values. The sampled activation for each example can have the correct distribution even when no full noisy weight matrix is explicitly instantiated for the minibatch.

This matters when optimisation noise, not the number of parameters alone, limits learning. Yet the trick has assumptions. A layer’s preactivation distribution must be computable or suitably approximated, and the objective needs compatible per-example structure. It is a technique for a particular stochastic computation graph rather than a universal cure for unstable training.

Back to contents

Define the mean-field Gaussian model before doing arithmetic

Suppose a layer uses a weight vector W with elements W_j independently distributed as Gaussian variables with means μ_j and variances σ_j². The approximation is called mean-field when it factorises over its specified weight components. Variance measures squared weight units and is nonnegative; standard deviation is the positive square root of variance.

For a fixed input vector x, the linear preactivation is b=sum_j x_j W_j. A weighted sum of independent Gaussian random variables is itself Gaussian. Its mean is sum_j x_j μ_j, while its variance is sum_j x_j² σ_j². Squaring the input coefficient in the variance term is essential, because multiplying a random variable by x multiplies its variance by x².

A network can combine this linear calculation with a bias and a nonlinear activation. The noise transformation occurs at the preactivation, before applying the activation. When the marginal distribution of that preactivation is preserved, passing it through the same deterministic nonlinear activation preserves each example’s marginal transformed distribution as well.

The diagonal variance formula relies on independence of the specified weights. If the weight posterior has correlations, the general variance is x transposed times the covariance matrix times x. Using only the diagonal elements while ignoring real posterior correlations changes the assumed distribution. A developer must know which approximate posterior family the model actually uses.

Back to contents

A global Gaussian draw is itself a reparameterization

The standard Gaussian reparameterization writes W_j=μ_j+σ_j ε_j, where ε_j is independently sampled from a standard normal distribution. This separates trainable distribution parameters from the random source. Automatic differentiation can then propagate through μ and σ as the network computes losses from the sampled weights.

For a minibatch, a simple implementation draws one ε vector for each weight matrix and applies that same resulting matrix to all examples. This is why the stochastic perturbation is global with respect to examples. The estimator can remain useful and well defined, but losses of different examples may share noise because they depend on the same ε values.

It would be incorrect to say the global estimator never benefits from a larger batch. Data-sampling variation can shrink, and correlations can vary with inputs and gradients. The point is narrower: a shared random component can produce covariance terms in the minibatch-average gradient variance, preventing the total from automatically scaling as one divided by batch size.

To compare alternatives fairly, hold the approximate posterior, loss definition and model architecture fixed. Then change only the sampling location. Otherwise any observed difference may be caused by a different posterior family, training objective or network capacity rather than the reparameterization trick itself.

Back to contents

Translate a weight distribution into local activation moments

For each input example m and output unit i, compute the preactivation mean M_mi=sum_j x_mj μ_ji. Under independent Gaussian weights, calculate the preactivation variance V_mi=sum_j x_mj² σ_ji². Draw an independent standard normal ε_mi for the example and output unit, and set b_mi=M_mi+sqrt(V_mi) ε_mi.

This expression produces the same Gaussian marginal distribution for b_mi that would result from a Gaussian weight draw followed by the usual linear multiplication. Instead of using one shared noisy W to perturb many examples, it samples from each example’s preactivation distribution directly. The local random array has a batch dimension, allowing different examples to use independent ε values.

In matrix notation for a fully connected layer, M=Xμ transposed under the chosen layout, and V=(X elementwise squared) multiplied by (σ²) transposed. The exact orientation varies between software libraries; dimensions and axes should be verified rather than memorised from one diagram. The variance calculation is another matrix multiplication, not a free operation.

The nonnegative square root of V converts variance to standard deviation. Numerical roundoff may occasionally produce tiny negative computed variances only if an implementation deviates from a nonnegative sum or uses unstable operations; such values need investigation rather than silently producing NaNs. Variance parameters themselves should be stored or transformed in a way that enforces nonnegativity.

Back to contents

Hand-check a layer with two uncertain weights

Take independent weight variables W1~N(1,0.25) and W2~N(2,1), where the first number is the mean and the second is the variance. Their standard deviations are 0.5 and 1. Choose a fixed input A=[2,1]. Its preactivation is b_A=2W1+1W2. The expected value is 2×1+1×2=4 activation units.

The variance is 2²×0.25+1²×1=1+1=2 squared activation units. Therefore b_A~N(4,2). A locally sampled value can be written as b_A=4+sqrt(2) ε_A with ε_A~N(0,1). The symbol ε_A is a constructed standard-normal draw variable, not an observed training result.

For a second input B=[1,2], the corresponding preactivation mean is 1×1+2×2=5. Its variance is 1²×0.25+2²×1=0.25+4=4.25. Thus b_B~N(5,4.25), and the local formula is b_B=5+sqrt(4.25) ε_B.

Check the units and arithmetic carefully. The means 4 and 5 are in activation units, variances 2 and 4.25 are in squared activation units, and sqrt(4.25)≈2.06155 is a standard deviation. The local method is not sampling two arbitrary activations; it is sampling precisely from the model-implied Gaussian marginal distributions under the stated assumptions.

Back to contents

A single global weight draw couples the two examples

Suppose the same sampled W1 and W2 are used for A and B. Their preactivations are b_A=2W1+W2 and b_B=W1+2W2. Although W1 and W2 are independent of each other, b_A and b_B are not independent because both depend on those same two sampled weights.

The covariance between the preactivations is sum_j x_Aj x_Bj Var(W_j) under the diagonal Gaussian model. Here it equals 2×1×0.25+1×2×1=0.5+2=2.5 squared activation units. This is a large shared-noise term relative to the individual variances 2 and 4.25.

The resulting correlation is 2.5 divided by sqrt(2×4.25), which is approximately 2.5/2.91548≈0.8575. That positive correlation means a global weight fluctuation tends to move the two preactivations together, even though their deterministic input vectors differ. This number follows from the deliberately chosen example; it is not a universal correlation for neural layers.

Local reparameterization can instead sample ε_A and ε_B independently, giving zero conditional covariance between their newly sampled noises for fixed inputs and distribution parameters. The marginals remain N(4,2) and N(5,4.25), but the joint distribution across the two examples is different from a shared global W draw. This distinction is essential, not an implementation footnote.

Back to contents

Preserving each example does not preserve arbitrary cross-example statistics

A model’s per-example loss is often of the form ℓ(y_m,f_W(x_m)), with a minibatch objective that sums or averages those losses. The expected value of a sum equals the sum of expected values, regardless of dependence among its terms. Therefore, replacing shared global noise with independent local noise can preserve the expected additive data-loss objective when each example’s marginal distribution is preserved.

But a statistic that explicitly compares examples can depend on their joint distribution. A cross-example covariance loss, a batch-coupled normalisation operation or a penalty comparing pairs of stochastic outputs can respond differently when common weight noise is replaced by independent activation noise. The transformation is not a licence to claim every possible network-level stochastic computation is exactly equivalent.

Even for a standard sum of likelihood terms, one must keep the right variational distribution and global regulariser. Local noise changes how the data expectation is estimated; it does not turn one global posterior over W into a set of independent Bayesian weight posteriors for every data point. That would be a different model.

A careful mathematical statement is therefore: under the layer and loss assumptions, local sampling preserves the relevant marginal distributions and expected additive loss terms, while often reducing estimator variance. It does not preserve all correlations across examples. This is precisely why it can help optimisation, and precisely why some applications need extra caution.

Back to contents

An invented noise draw shows what is actually sampled

Return to the two-input illustration. Suppose local ε_A happens to be zero, while ε_B happens to be one. The locally generated activation for A is 4+sqrt(2)×0=4. The generated activation for B is 5+sqrt(4.25)×1≈7.06155. Those values are one possible manually chosen sample pair, not a training observation.

With global sampling, a single pair of weight noises would determine both b_A and b_B. You cannot generally select b_A and b_B independently while insisting that they arise from the same two sampled weights with the same cross-example covariance. Local sampling deliberately makes that independence possible for the estimator.

If the training objective is the sum of separate losses for A and B, we can compute expectations with respect to each of their correct marginals. A Monte Carlo estimate may be noisier or quieter depending on how its terms covary. Local independence removes one systematic source of covariance, but no one sample pair proves the variance advantage.

To demonstrate the expected-value relationship with code, use many fixed-seed draws of each estimator for a small differentiable loss and compare Monte Carlo averages to a high-precision reference. Report uncertainty in the estimates and ensure the original approximate posterior is identical. Do not infer correctness merely because one randomly drawn output seems reasonable.

Back to contents

Why shared covariance changes how a batch average behaves

For minibatch gradient contributions g1,…,gM, the variance of their average is one over M squared times the sum of all variances and covariances. If each contribution has variance v and every pair of distinct contributions has the same covariance c, this simplifies to v/M+(M-1)c/M. That second term is why shared randomness can remain influential as M increases.

If the contributions are independent under the relevant conditions, c=0 and the variance becomes v/M. If they remain positively correlated under one common random weight draw, averaging more examples does not necessarily eliminate the common component. This is the statistical motivation behind moving global noise into independent per-example activation variables.

The original Kingma, Salimans and Welling paper explains this variance-reduction benefit for its stochastic-gradient variational Bayes setting. An engineer should still check whether gradients are truly close to independent conditional on the minibatch in the actual architecture. Weight sharing, data correlations, batch losses and optimisation details may affect the observed pattern.

The expression is not a universal proof of faster convergence. Reduced estimator variance can improve optimisation efficiency, but realised training speed also depends on computation per step, learning-rate choices, numerical precision and hardware. Measure both gradient variance and total time or compute to reach a declared held-out objective.

Back to contents

Worked variance comparison with a declared covariance

Construct a separate statistical illustration in which each example’s scalar gradient contribution has variance v=4 squared gradient units. Under a global sampling method suppose the covariance between two distinct examples’ gradient contributions is c=1 squared gradient unit. With M=8 examples, variance of the mean is 4/8+(8-1)×1/8=0.5+0.875=1.375.

Under a hypothetical local method with equal individual gradient variance v=4 but zero covariance across the eight contributions, variance of the mean becomes 4/8=0.5. That is a reduction of 1.375-0.5=0.875 squared gradient units, or about 63.64 percent relative to 1.375 in this constructed scenario.

The numbers v=4 and c=1 are stipulated to illustrate the equation, not derived from our earlier activation example and not reported from the paper. Gradient covariance generally depends on nonlinear loss derivatives as well as activation covariance. One cannot substitute preactivation covariance directly into the gradient variance formula without doing the appropriate differentiation.

The important denominator is the number M=8 of contributions averaged; the seven in the covariance term counts other contributions paired with each one. In a real minibatch, different contributions can have unequal variances and pairwise covariances, so the full covariance sum may be needed. This simple arithmetic explains the mechanism without pretending every model reaches an exact percentage improvement.

Back to contents

Sampling activations changes the array sizes and computational work

A dense layer with 1,000 input features and 2,000 output features has two million weight parameters. Drawing a global independent noise value for every weight involves two million random numbers for one sampled matrix. A minibatch of 128 inputs has 128×2,000=256,000 output preactivations, so a local noise draw at the output involves 256,000 normal samples.

For this illustrative shape, the ratio of global sampled weight noise count to local activation noise count is 2,000,000/256,000=7.8125. That does not automatically imply an eightfold memory or speed improvement. Local computation also requires both a mean multiplication and a variance multiplication, and different frameworks store intermediates differently.

For a much larger batch, local activation noise can exceed weight noise in count. For example, 2,048 examples times 2,000 outputs is 4,096,000 local random values, more than the two million weight components. The advantage of local reparameterization is primarily estimator structure and parallelism, not a guarantee of fewer random values in every layer configuration.

Measure actual peak memory, random-number generation costs, matrix-multiplication throughput and time to a declared accuracy target. A method that uses more floating-point operations per update might still win by requiring fewer noisy updates. Conversely, a model with little weight-sampling variance may gain little and pay extra computational overhead.

Back to contents

The shape of local noise must match the preactivation layout

Suppose inputs are stored in a batch-by-input-feature matrix X of shape M×D, and a linear layer produces O output units. Means and variances of weights have shape D×O under one common programming convention. The mean preactivation matrix Xμ and variance matrix (X squared)(σ²) each have shape M×O.

The local standard normal array should therefore also have shape M×O in that convention. Sampling one ε per output feature and broadcasting it across the entire batch recreates a common-noise component and defeats the intended independence. Sampling one scalar per minibatch does even less to separate examples. A tensor can have the expected final shape after broadcasting while still using the wrong random structure.

Tests should inspect not only output shape and mean but empirical cross-example covariance across many independent draws with inputs held fixed. If local noise is truly independent for distinct examples and output units under the simplified model, its conditional sample covariance should approach zero as the number of draws grows. Finite samples can show nonzero deviations without indicating a defect.

Different frameworks transpose their weight matrices, and convolutional layers use different layouts again. A published formula is a starting point, not permission to hard-code an axis number into every model. Record input dimensions, which axis indexes output units and where independent noise is generated.

Back to contents

Where nonlinearities can and cannot be moved

If the preactivation b of one example has a known Gaussian marginal and the neural network applies a deterministic activation h(b), sampling b locally and then applying h preserves the marginal distribution of h(b). A rectified linear unit, for instance, simply maps the sampled preactivation through max(0,b). The output distribution is no longer Gaussian, but local sampling does not require it to be Gaussian after the activation.

However, moving noise to a later layer without recomputing the correct distribution is generally invalid. Once uncertain outputs pass through nonlinear functions, the next preactivation may no longer have the simple Gaussian form derived for fixed inputs and independent Gaussian weights. A fresh moment calculation or approximation is necessary if another local sampling step is attempted.

Batch normalisation is especially important because it can couple examples through minibatch statistics. If the objective or network computation depends on those jointly sampled statistics, preserving individual preactivation marginals may not preserve the expected batch-coupled computation. An implementation should treat that as a modelling question, not a merely numerical implementation detail.

The appropriate test compares local and global estimators on the actual computational graph, not just on one standalone linear layer. Start with a simple additive loss, then add nonlinearities and any cross-example operations one at a time. Find the point where expected-value equivalence or gradient behaviour changes.

Back to contents

Weight sharing across spatial locations introduces another dependency

A convolutional filter is reused across many spatial positions. Under a random global filter draw, activations at different positions in the same image can share weight uncertainty, just as different examples do in a dense layer. Replacing every position’s noise with an independent Gaussian draw preserves some marginal moments but can alter the correlations among positions and channels.

Those correlations may matter because later convolutions or pooling operations combine neighbouring positions. A naive extension that assumes all local activations can be independently sampled can change the effective joint model. The original local-reparameterization derivation should not be casually extended beyond its stated assumptions, even when software can broadcast a variance tensor across images.

Some architectures admit more careful structured estimators, while others benefit from drawing shared variables at a more suitable granularity. The correct noise-sharing pattern depends on the model and objective. A formula derived for independently weighted dense preactivations is not enough to settle every convolutional case.

Before using a local trick in a vision model, test a tiny image and filter against a high-sample global-weight reference. Compare means, variances, spatial covariance and downstream loss estimates. A single matching pixel variance does not establish equivalence of a full image prediction.

Back to contents

Local sampling changes a data-term estimator, not the global posterior

Stochastic gradient variational Bayes optimises an objective involving expected data fit under an approximate parameter posterior and a regularising divergence to a prior. For a factorised data likelihood, the data term can be written as a sum of expected log likelihoods over examples. The KL divergence between the global q(W) and p(W) is a separate model-level term.

Local reparameterization provides a different Monte Carlo route to the per-example expected data term. It does not replace the KL term with a new KL for each locally sampled activation, and it does not give every training case an independent copy of the learned weights in the model definition. That distinction prevents an accidental change of the intended variational objective.

Minibatch training needs an explicit scaling convention. If the objective is a sum over all N training cases and only B cases are sampled uniformly, the sampled log-likelihood sum is often multiplied by N/B for an unbiased estimator of the full sum under standard assumptions. A mean-per-datapoint objective uses different normalisation; the KL factor must be adjusted consistently.

A training implementation that accidentally multiplies the global KL by the batch size or forgets the dataset scaling can look like an optimisation instability. Such a bug will not be repaired by choosing a better random noise location. Write down the objective in mathematical units before tuning learning rates or dropout parameters.

Back to contents

A hand-checked evidence-bound scaling exercise

Construct a dataset of N=10,000 training observations. A minibatch contains B=100 uniformly sampled observations. Suppose the sum of sampled expected log-likelihood estimates for that batch is -250 in log-score units. Under a summed objective, the full-data estimator scales that quantity by N/B=100, giving -25,000 log-score units.

Suppose the corresponding global KL divergence is 600 in the same dimensionless log units. The illustrative estimated evidence-lower-bound contribution is then -25,000-600=-25,600. We are not claiming that any real dataset or network has those values; they are deliberately chosen for checking the scaling.

If an implementation instead simply subtracts 600 from -250 without changing the convention, it is mixing one minibatch’s data term with a whole-model regulariser. If it multiplies 600 by 100 again while also scaling the data, it penalises the posterior too strongly. Both errors can change training behaviour more than the local noise technique.

When the objective is expressed as an average per training case, the corresponding average data term and KL/N convention can be used instead. Compare code against one complete-batch toy example to verify the scaling before introducing random minibatches. Local reparameterization is an estimator method, not a way around basic objective accounting.

Back to contents

How Gaussian dropout connects to weight uncertainty

Gaussian dropout uses multiplicative random noise with mean one. For a single deterministic weight parameter θ, one possible form is W=θ(1+sqrt(α)ε), where ε is standard normal. The mean of W is θ and its variance is αθ². The parameter α controls variance relative to the square of the mean; it is not a Bernoulli probability of deleting a unit.

For θ=[1,2] and α=0.25 applied independently to the weights, the implied variances are [0.25×1²,0.25×2²]=[0.25,1]. These are exactly the weight moments used in our earlier two-input numerical illustration. Consequently, input A=[2,1] has mean preactivation four and variance two under that simplified construction.

The original 2015 research explained a relationship between Gaussian dropout objectives and a particular variational formulation involving a scale-invariant prior and posterior variance proportional to squared weight means. The same mathematical local sampling idea also applies more broadly to appropriate Gaussian variational parameterisations, not only to fixed-rate Gaussian dropout.

Avoid conflating Gaussian dropout with Bernoulli dropout. Bernoulli dropout can set selected units or features to zero according to a discrete mask, whereas Gaussian multiplicative noise takes continuous values and may even be negative. Their training objectives and exact noise distributions are not interchangeable simply because both are called dropout.

Back to contents

Learned dropout rates raise extra modelling questions

One contribution of the original variational dropout work was to treat some dropout parameters as learnable instead of fixing them all in advance. A model could adapt the amount of posterior weight variance in response to the objective, potentially exploring regularisation patterns that a single manually selected rate would miss. The local sampling technique makes training those distributions more practical under the paper’s assumptions.

In a simple parameterisation Var(W)=αθ², increasing α broadens the distribution relative to the square of its mean. A low α corresponds to relatively concentrated weights. The learning signal for α depends on the data fit and regularising terms, their parameterisation and numerical constraints. It should not be interpreted as an automatically calibrated confidence score about the model’s correctness.

Later work, including Molchanov and colleagues’ 2017 study, explored learning individual noise parameters to encourage sparsity. Those results are research claims in specified architectures and benchmarks, not a blanket guarantee that learned dropout rates always produce compressed, more accurate or better calibrated models.

A clean article about the local reparameterization trick should keep these extensions in context. The transformation that samples local Gaussian activations can be useful even when an organisation has no intention of learning dropout rates or pruning weights. It solves a gradient-estimation problem, whereas sparse model selection is another objective with additional assumptions.

Back to contents

The log-uniform prior interpretation has substantive limitations

An important later critique came from Hron, Matthews and Ghahramani in their work titled Variational Gaussian Dropout is not Bayesian. They analysed the log-uniform prior used in prominent variational dropout formulations and argued that it can lead to an improper posterior, undermining the ordinary probabilistic interpretation. This concerns a particular Bayesian modelling claim, not the algebra of sampling Gaussian preactivations.

An improper prior does not automatically define a meaningful proper posterior under every likelihood. If the posterior cannot be normalised, a computed objective should not be casually described as a rigorous lower bound on a finite model evidence. Such distinctions matter when an article or software library advertises calibrated Bayesian uncertainty simply because it implements variational dropout.

The existence of this critique does not invalidate all variational inference or every possible proper-prior Gaussian posterior. A properly defined approximate posterior over independent Gaussian weights still leads to the same elementary linear-combination formulas. Whether an estimator preserves the intended expected data term is a mathematical question separate from whether the selected prior gives a coherent full Bayesian model.

For a fair implementation review, identify exactly which variational objective is being optimised, whether the prior is proper, how KL is treated and which claims of uncertainty or sparsity depend on the contested assumptions. Cite the original 2015 paper and the later 2017 critique instead of presenting one side as though the debate never occurred.

Back to contents

Reduced gradient noise is not the same as predictive calibration

The method aims to reduce variance in a stochastic-gradient estimator. Variance of gradients across random training draws is not the same as variance of predictions across uncertain parameters, and neither is automatically a calibrated probability that a deployed decision will be correct. Those quantities operate at different stages of the learning system.

A network can have low gradient-estimation variance and still learn the wrong relationship because labels are corrupt, training data are biased or the model is misspecified. Local reparameterization cannot fix a defective objective or guarantee out-of-distribution performance. It may help an optimiser reach a chosen objective more efficiently, but the choice of objective remains a separate engineering decision.

Likewise, the approximate Gaussian posterior may represent only a narrow family of possible parameter distributions. If the real posterior has strong correlations or multiple distinct modes, a mean-field approximation can understate important uncertainty. Improving the Monte Carlo estimator for that family does not make the family itself an exact description of the true uncertainty.

Evaluate predictive accuracy, calibration where appropriate, robustness under changed data and compute cost independently of gradient variance. This prevents a variance-reduction mechanism from being promoted as a universal reliability technology.

Back to contents

Find the earliest layer where equivalence fails

Start with a one-output linear layer and fixed inputs. Compare analytic means and variances against repeated global-weight samples and repeated local activation samples. If either set disagrees with analytic moments, inspect weight-layout conventions, variance squaring, random noise shape and whether standard deviations were confused with variances.

Next compare two fixed examples. Global draws should reproduce their predicted covariance when the same uncertain weights are reused. Local independent noises should reproduce each marginal while suppressing that conditional shared-noise covariance. If both estimators appear identical even in their joint covariance, the local implementation may inadvertently be sharing ε across the batch.

Then attach a separable nonlinear loss and compare Monte Carlo estimates of the expected summed loss under the two methods, with uncertainty intervals from many independent repetitions. If the expected values disagree beyond sampling error, check whether a later batch-coupled operation, miscomputed Gaussian moments or a different objective has entered the graph.

Finally compare gradient variance and held-out learning under a fixed architecture, data split, hyperparameter budget and computing environment. Record training-time cost rather than only iteration count. The source of a discrepancy should be diagnosed before an engineer labels the entire local reparameterization technique ineffective.

Back to contents

Stable variance parameters and small values deserve attention

A variance parameter must remain nonnegative. A common implementation stores a transformed parameter such as a log variance or uses a smooth positive mapping from an unconstrained raw parameter. Whichever choice is made, verify how gradients propagate into variance when values become very small or very large.

The sampled preactivation uses sqrt(V). If V approaches zero, its standard deviation becomes small and the local draw approaches the deterministic mean. Numerical behaviour near zero can be sensitive to finite precision and the chosen parameterisation. Adding an arbitrary large constant to V to prevent numerical issues changes the model’s intended distribution.

Large input magnitudes can multiply variance through x², so normalising features and monitoring activation scales are useful. A model trained on one feature scale may show different relative stochastic effects on another scale. Standardising data is not a substitute for correct variance formulas, but it can make the relevant numerical range easier to manage.

The test suite should include zero inputs, negative inputs, extremely small posterior variances, multiple output units and intentionally correlated weights that violate the diagonal assumption. A good failure test explains which assumption was broken instead of silently forcing all cases through the simple formula.

Back to contents

Changed-context transfer: add a third uncertain weight

Try a changed-context problem. Extend our original independent weight model with W3~N(-1,0.36) and choose a new input C=[2,1,3]. The first two weights remain W1~N(1,0.25) and W2~N(2,1). What are the mean and variance of C’s preactivation, and how should one draw a local sample?

The mean is 2×1+1×2+3×(-1)=2+2-3=1 activation unit. Under independence, the variance is 2²×0.25+1²×1+3²×0.36=1+1+3.24=5.24 squared activation units. The standard deviation is sqrt(5.24)≈2.28910 activation units.

A locally reparameterized preactivation is therefore b_C=1+sqrt(5.24)ε_C with an independent standard normal ε_C. The negative mean of W3 is allowed; variance uses squared coefficients and remains nonnegative. No shared random W draw is needed to sample that single marginal conditional on the model parameters.

Now change the assumption: suppose W1 and W3 have covariance 0.1 squared weight units while all other cross-covariances remain zero. The additional covariance contribution is 2×2×3×0.1=1.2, so the new preactivation variance becomes 5.24+1.2=6.44. This last calculation proves why blindly applying the diagonal formula to a correlated posterior would be wrong.

Back to contents

A rigorous comparison separates estimator quality from model quality

A research comparison should first test whether global and local sampling optimise the same intended expected additive objective under the chosen posterior. Use analytic toy cases and high-sample Monte Carlo estimates as a reference. Once this is confirmed, compare gradient variance at matched parameters rather than inferring it indirectly from one noisy learning curve.

Next test training efficiency with the same architecture and data split. Report the number of optimiser updates, wall-clock time, batch size, hardware, posterior family and learning-rate selection. A lower-variance estimator can reach a comparable objective with fewer steps yet still cost more per step due to extra variance multiplications.

Finally evaluate real held-out quality. Prediction accuracy, calibration, decision errors under shift and robustness are independent of how the gradient estimator was constructed. A result obtained on one benchmark cannot establish superiority for every dataset. Use multiple seeds and a clearly stated model-selection protocol, not the best single run from each method.

Also quantify memory and tensor shapes. Local ε arrays scale with batch size times output dimension, whereas global ε arrays scale with the number of sampled weights. Training activations and gradient tapes can dominate either count. Reporting complete peak memory is more useful than comparing just the number of random variates sampled.

Back to contents

When to use the trick and when not to add it

The local reparameterization trick is a sensible candidate when a layer has a tractable Gaussian preactivation under a suitable approximate posterior, the loss decomposes by example, global weight-sampling covariance materially increases gradient noise, and the application can benefit from more stable stochastic variational optimisation.

It is not automatically useful for a deterministic model with no random weight distribution. It may also be inappropriate when the downstream loss depends on joint uncertainty across examples or the model relies heavily on shared random variables whose correlations are meaningful. Some architectures need a specialised estimator rather than naive independent local noise.

An organisation interested only in test-time model uncertainty should examine whether the approximate posterior is valid and calibrated before choosing a training trick. The existing Monte Carlo Dropout guide examines stochastic predictions and calibration limits, a different reader problem from replacing global stochastic-gradient sampling with local activation noise.

The enduring lesson is that one can change how an expectation is estimated without changing the expectation itself, provided the required assumptions hold. That can be powerful because estimator variance influences how efficiently a model learns. It is equally important to recognise when an altered joint distribution makes the supposed equivalence invalid.

Back to contents

Frequently asked questions about local reparameterization

What exactly is reparameterized?

For independent Gaussian weights in a linear layer, uncertainty about sampled global weights is translated into a Gaussian distribution over each example’s preactivation. The implementation samples the preactivation using its computed mean and standard deviation rather than first instantiating a single noisy weight matrix for the whole minibatch.

Does local sampling preserve the same joint outputs?

Not generally. It preserves the relevant per-example marginal preactivation distributions under the assumptions. Independent local noises remove correlations that global shared-weight samples would induce across different examples. This can preserve expected additive losses while changing cross-example joint statistics.

Why can it reduce stochastic-gradient variance?

With a shared weight draw, contributions from different examples may have correlated sampling noise, so averaging them does not eliminate all variance. Independent local samples remove one common component. Actual improvement depends on model architecture, loss and gradient covariance.

Is the method equivalent to ordinary Bernoulli dropout?

No. Gaussian dropout uses continuous multiplicative noise. A Gaussian noise variance parameter α is not the probability of dropping a unit. The original paper related certain Gaussian dropout objectives to a variational formulation under specific assumptions.

Can it be used with correlated Gaussian weights?

The simple diagonal formula is inadequate when weights are correlated. The general preactivation variance includes covariance cross-terms x transposed Σ x. A method for correlated posteriors must preserve appropriate moments and any joint structure required by the task.

Does the technique establish that uncertainty is calibrated?

No. Reducing gradient estimator variance does not validate the approximate posterior, prior, labels or model predictions. Calibration and out-of-distribution performance require separate testing.

What is the role of the KL divergence?

The global approximate posterior q(W) can be regularised against a prior p(W). Local activation sampling changes the Monte Carlo estimation of per-example data terms; it does not turn that global KL into a separate penalty for each locally sampled activation.

What is the limitation of the log-uniform prior?

Later work by Hron, Matthews and Ghahramani argued that particular variational Gaussian-dropout constructions with log-uniform priors can yield improper posteriors. That challenges those Bayesian interpretations, not the elementary Gaussian linear-combination identity behind local activation sampling.

What should a first unit test include?

Use two independent weights with means [1,2] and variances [0.25,1]. For input [2,1], check activation mean 4 and variance 2. For input [1,2], check mean 5 and variance 4.25. Compare global-sample covariance 2.5 against the independent local-noise calculation.

How should production teams decide whether to adopt it?

Check the objective’s additive structure, weight-posterior assumptions, empirical gradient variance, actual compute and memory costs, held-out performance and whether batch-coupled operations invalidate marginal-based replacement. Do not treat a paper’s general optimisation result as a deployment guarantee.

Original research and later limitations

Kingma, Salimans and Welling (2015), Variational Dropout and the Local Reparameterization Trick, NeurIPS. Original research on changing the sampling location for lower-variance stochastic-gradient variational inference.

Open manuscript of the 2015 local reparameterization work. See its mathematical distinctions among global weights, local preactivation noise, Gaussian dropout and variational objectives.

Molchanov, Ashukha and Vetrov (2017), Variational Dropout Sparsifies Deep Neural Networks. A later extension investigating learnable noise and model sparsity under particular assumptions, not evidence of a universal result.

Hron, Matthews and Ghahramani (2017), Variational Gaussian Dropout is not Bayesian. A substantive critique of the propriety of particular log-uniform-prior formulations; readers should distinguish this from the algebraic local-sampling transformation.

Start with How AI Works for the broader picture of parameter learning, stochastic optimisation and evaluation. The local reparameterization trick addresses one specific estimator problem within that system.

Read Monte Carlo Dropout — Stochastic Predictions, Uncertainty and Calibration Limits for a distinct reader need centred on prediction uncertainty rather than the sampling location of minibatch gradients.

For a different relationship between parameter randomness and optimisation, read Stochastic Gradient Langevin Dynamics — Mini-batch Posterior Sampling and Noise. SGLD adds noise to optimisation updates under its own sampling assumptions, whereas local reparameterization changes stochastic evaluation inside a variational model.

Final self-test: derive one preactivation mean and variance from Gaussian weights, calculate cross-example covariance under shared sampling, remove that covariance through independent local noise, and explain why the expected additive objective can remain unchanged even though the joint output law differs.