An artificial neural network is a parameterized system of interconnected computational units whose outputs depend on weighted inputs. A feedforward neural network commonly composes layerswhere are weight matrices, are biases and are activation functions. Recurrent neural networks instead reuse a state through time; weight sharing also imposes structure in a convolutional neural network.
A loss function measures how well outputs serve the task. Backpropagation applies the chain rule to compute parameter gradients, which an optimization algorithm can use for learning. For example, a hidden rectified unit followed by a weighted output represents a piecewise affine function. With identity activations in every hidden layer, successive affine maps collapse to one affine map, so depth alone adds no nonlinear expressiveness.
The useful representation depends on architecture, data and training. Fitting many parameters does not establish generalization; regularization, independent evaluation and the target data distribution remain relevant.
A neural network logit is a real-valued class score produced before a probability transformation such as the softmax function. The vector of scores determines the class probabilities jointly; an isolated score is not itself a probability. Negative scores and scores larger than one are permitted.[ref]
On Calibration of Modern Neural Networks by Chuan Guo and others. §4.2, paragraph before Eq. (8), logits before the softmax layer
For scores , the softmax function givesAdding one common scalar to every coordinate leaves all probabilities unchanged:Consequently the absolute offset of a logit vector cannot be recovered from these probabilities.
For example, scores and both give first-class probability . The difference between the two scores, rather than the first coordinate alone, determines this binary probability. Indeed,This connects the binary score difference with the logit link function. It does not make every coordinate of a multiclass score vector a separately defined binary log-odds.
A common shift also differs from rescaling. Dividing by two gives and first-class probability . This is the transformation used in temperature scaling with temperature two. Positive scaling preserves the selected class within an example while changing confidence.[ref]
When interpreting a neural network logit, state its score vector and probability transformation. Comparing raw coordinates from independently shifted parameterizations can otherwise suggest a confidence change where the actual probability vector is identical.
Long short-term memory, usually abbreviated LSTM, is a recurrent neural network architecture that carries an explicit memory state through a sequence and learns when to write, retain and expose its contents. It addresses the vanishing gradient problem: in ordinary recurrence, repeated multiplication by small derivatives can make a distant input have almost no effect on the gradient used for learning. Sepp Hochreiter and Jürgen Schmidhuber's 1997 architecture provided a memory-cell path designed to preserve error flow, with gates controlling access.[ref]
Long Short-Term Memory by Sepp Hochreiter and Jürgen Schmidhuber. Abstract and memory-cell construction: constant error flow and input/output gates.
A common simplified modern form, omitting peephole connections, isHere is the input, the memory, the exposed state, the logistic sigmoid function, the hyperbolic tangent, and componentwise multiplication. The learned matrices and biases determine an input gate in long short-term memory , a forget gate in long short-term memory , and an output gate in long short-term memory . LSTM: A Search Space Odyssey by Klaus Greff and others gives a more general baseline with peephole connections; the equations above deliberately show the simpler variant.[ref]
LSTM: A Search Space Odyssey by Klaus Greff and others. Section II and Figure 1: gate roles and baseline update equations.
For a scalar memory with writing switched off in the idealized limit and constant retention , . Over 100 steps, retains about , while retains about . This illustrates how a learned gate can select a retention timescale. Exactly zero or one are limiting idealizations for a finite-input logistic sigmoid function. The product of forget gates describes the direct memory path; it is not the entire recurrent derivative, because gates also depend on earlier states.
The forget gate in long short-term memory was introduced after the original architecture, in Learning to Forget: Continual Prediction with LSTM by Felix A. Gers, Jürgen Schmidhuber and Fred Cummins, to allow old contents to be reset during continuing input streams. Training still uses methods such as backpropagation through time. Artificial delayed-dependency tasks in the original paper demonstrated learning across more than 1,000 time steps in particular experiments; this does not imply unlimited memory or guaranteed success on every long sequence.[ref]
Learning to Forget: Continual Prediction with LSTM by Felix A. Gers, Jürgen Schmidhuber and Fred Cummins. Abstract and adaptive forget-gate motivation.
[ref]Long Short-Term Memory by Sepp Hochreiter and Jürgen Schmidhuber. Abstract and long-delay task experiments.
An LSTM memory cell is the state-carrying unit of a long short-term memory recurrent neural network. It maintains an internal memory whose update is controlled by gates, while an exposed state communicates selected information to the rest of the network. The memory and exposed output are different quantities.[ref]
Long Short-Term Memory by Sepp Hochreiter and Jürgen Schmidhuber. Memory-cell construction and gated access to persistent state.
In a simplified modern form, omitting peepholes,The LSTM forget gate regulates retention, the LSTM input gate regulates the candidate write , and the LSTM output gate regulates exposure. The componentwise product allows different memory coordinates to make different decisions.[ref]
LSTM: A Search Space Odyssey by Klaus Greff and others. Section II and Figure 1; the displayed simplified variant omits the baseline's peephole connections.
For a scalar example, , , and give . If , the output is only . A small output can coexist with substantial stored state; it does not demonstrate memory erasure.
The additive state path was designed to help learning across long delays. The original 1997 architecture had input/output gating; adaptive forgetting was introduced later for continuing streams. Preserving a direct gradient path addresses an important learning difficulty but does not guarantee unlimited or perfectly reliable memory for every task.[ref]
Long Short-Term Memory by Sepp Hochreiter and Jürgen Schmidhuber. Constant error flow and delayed-dependency experiments.
[ref]Learning to Forget: Continual Prediction with LSTM by Felix A. Gers, Jürgen Schmidhuber and Fred Cummins. Adaptive forget gate and continual prediction.
The output gate in long short-term memory controls how much stored memory is exposed as the recurrent output of a long short-term memory network. In a common form,The memory is , the exposed state is , is a logistic sigmoid function, and is the hyperbolic tangent. The output gate in long short-term memory modulates the exposed state rather than directly multiplying the stored memory itself.[ref]
LSTM: A Search Space Odyssey by Klaus Greff and others. Section II, Figure 1: output activation and gate; simplified no-peephole equations.
For example, if , then . An output gate yields , whereas yields . Both cases can have the same current memory. A small exposed value therefore does not establish that the internal memory has been erased.
Selective exposure lets a network retain information until it becomes useful for a later prediction. The original architecture combined output gating with an input gate in long short-term memory to regulate access to persistent memory. Changing the exposed state may affect later gate decisions, so “does not directly erase” does not mean the output gate has no influence on future memory evolution.[ref]
Long Short-Term Memory by Sepp Hochreiter and Jürgen Schmidhuber. Memory-cell input/output gates and long-delay learning motivation.
The forget gate in long short-term memory controls retention of the previous memory state in a long short-term memory recurrent neural network. In a simplified modern update,Each component of multiplies the corresponding old memory component. Values near one retain it strongly; values near zero suppress it. The input gate in long short-term memory controls the separate new-write term.[ref]
LSTM: A Search Space Odyssey by Klaus Greff and others. Section II and Figure 1; simplified form here omits peepholes.
If a scalar gate stays at and the new-write term is zero, then after steps . The half-retention time isThis gives an interpretable timescale for a learned multiplicative gate. An exact no-write term is an illustrative condition; finite logistic sigmoid function outputs are strictly between zero and one, though the candidate can itself be zero.
The forget gate was added after the 1997 architecture. Felix A. Gers, Jürgen Schmidhuber and Fred Cummins introduced adaptive forgetting to handle continuing streams where a memory needs to be reset rather than preserved indefinitely. The direct memory-path derivative contains products of forget gates; the full recurrent derivative also includes dependencies through other states and gates.[ref]
Learning to Forget: Continual Prediction with LSTM by Felix A. Gers, Jürgen Schmidhuber and Fred Cummins. Abstract and adaptive forget-gate motivation for continual prediction.
The input gate in long short-term memory controls how much proposed new information is written into the memory state of a long short-term memory recurrent neural network. In a common modern form,Here is the candidate memory update, is the input-gate vector, and means componentwise multiplication. The sigmoid function places each gate component between zero and one. The forget gate in long short-term memory separately controls the existing memory: suppressing a new write does not by itself erase stored information.[ref]
LSTM: A Search Space Odyssey by Klaus Greff and others. Section II, Figure 1: memory update and input-gate role; equations here omit peephole connections.
For a scalar example, let , , and . Then . Increasing only to gives : a larger gate admits more of the negative candidate. The gate is a multiplier, not an instruction that the memory must increase.
The proposed write and its admission are learned separately. An input may suggest a strong candidate while the gate learns that this timestep should be ignored. This selective writing was part of the original memory-cell strategy for protecting information across long delays, together with gated reading through the output gate in long short-term memory.[ref]
Long Short-Term Memory by Sepp Hochreiter and Jürgen Schmidhuber. Memory-cell construction and input/output gates protecting constant error flow.
A network in which competition allows the strongest responding unit to dominate while suppressing alternatives. A sparse winning population is a softer variant; inhibition and normalization specify the mechanism rather than following automatically from a diagram.
Repeated differentiation through a deep or recurrent neural network can make some gradient components extremely large. In the scalar recurrence , the derivative with respect to is , which grows exponentially if . Large individual matrix norms alone do not imply such growth, because directions can change or cancel; the full product of step Jacobian matrices determines the effect.
Repeated differentiation through a deep or recurrent neural network can make gradients associated with distant layers or earlier sequence positions extremely small. A simple mechanism is a product of step Jacobian matrices whose operator norms are all bounded above by some : the product operator norm is then at most over steps by submultiplicativity. This can impede learning long-range dependencies in a recurrent neural network.
A neural network whose hidden state follows a recurrence with shared parameters. It represents dependence across sequence positions through its hidden state. The standard recurrence is sequential across positions, and differentiation through many steps multiplies step Jacobian matrices, potentially causing a vanishing gradient or an exploding gradient.
A recurrent architecture that uses learned gates to regulate state preservation, replacement or readout. Gating can improve useful memory and learning over long intervals, but does not by itself establish biological implementation or solve arbitrary temporal credit assignment.
A recurrent network with a continuous family of stable or approximately stable activity patterns, such as a localized bump at any angle on a ring. Recurrent dynamics maintain the represented variable while motion-related input updates it and sensory input anchors it. Postulating the attractor family does not by itself explain its developmental origin.
A training regularization method that randomly removes selected activations or connections. In inverted dropout with keep probability , multiply each retained activation by , so its conditional expectation equals the original activation; inference then uses the unmasked activations. The random masks discourage dependence on a particular small collection of activations.
A connection that adds a sublayer's input to its output, using a projection when dimensions require it. Its derivative is , so the derivative has a direct identity contribution in addition to the sublayer's contribution. This supports propagation through a deep network but does not itself guarantee bounded gradients.
For , define and . Layer normalization returns , with learned coordinatewise scale , shift , and fixed . In a transformer block, this normalization is applied across feature coordinates separately within each example and sequence position; it does not average over a batch.
The layer-normalization bias is the learned coordinatewise offset applied after the normalized core and layer-normalization gain. Writing the core as ,The offset is a model parameter, rather than an estimate of statistical bias. The PyTorch implementation provides an optional learned additive parameter for each normalized element.[ref]
LayerNorm in the PyTorch documentation. 2.15, equation and Variables/bias; Parameters/bias and elementwise_affine
An original constant-input example isolates its effect. Choose and any positive layer-normalization epsilon. The core is zero, so for the output is exactly , regardless of the fixed gain. Its coordinate arithmetic mean is : the output of the full learned layer need not have zero mean even though its normalized core does.
For a scalar loss with incoming output gradient , the chain rule gives . For the original loss in this example, the bias gradient is therefore . If the same parameter vector is reused at several positions, their gradient contributions add.
An equal shift of every coordinate before normalization is removed, as shown in layer normalization is invariant under a common input shift. The offset here is applied after normalization and persists. When differentiating only with respect to while parameters are fixed, contributes zero to the layer-normalization Jacobian.
The layer-normalization gain is the learned coordinatewise multiplier applied to the normalized core. With layer-normalization bias , the output is , where is the Hadamard product. The multiplier can differ between coordinates and need not be positive.[ref]
LayerNorm in the PyTorch documentation. 2.15, equation; Variables/weight and Parameters/elementwise_affine
It permits the model to rescale the features after normalization.For an original example, choose and layer-normalization epsilon . The coordinate mean is zero, the coordinate variance is , and the normalized core is . Taking and zero bias givesThe output coordinate arithmetic mean is and its coordinate variance is . Thus the core's centering and variance properties do not automatically survive unequal gains. A negative gain also reverses the sign of its coordinate in this example.
If is the incoming loss gradient, then . For above, the gain gradient is . This concerns a derivative with respect to the learned parameter; the layer-normalization Jacobian instead differentiates with respect to the input with parameters fixed.
Setting one to zero makes that output coordinate equal to its bias, but does not remove input coordinate from the shared normalization statistics. It can still influence other output coordinates through those statistics. The input derivative is obtained by multiplying the core Jacobian on the left by the diagonal matrix of gains. Layer-normalization epsilon contains the general derivative and bound.
The layer-normalization Jacobian describes the first-order response of the normalized core to a change in its input. Let be the core defined in layer-normalization epsilon, with . Its Jacobian matrix satisfiesThe closed formula and its derivation are given in layer-normalization epsilon. A matrix entry measures the local effect of changing input coordinate on normalized output coordinate .
An original two-coordinate calculation takes and . Here the centered variance is and the normalized core is . Substitution into the established derivative formula givesConsequentlyThe common-offset direction has no effect; the centered contrast direction changes the output. This is a local linear response, rather than an exact rule for arbitrary finite changes.
For the complete output with fixed layer-normalization gain and layer-normalization bias, the input Jacobian is . In the example, givesThe first output is suppressed, yet the first input still affects the second output. This distinguishes an output gain from removing an input feature. Parameter derivatives with respect to and are separate derivatives. Layer-normalization sensitivity measures the input Jacobian's amplification through an operator norm.
Adding the same scalar to every coordinate leaves layer normalization unchanged, provided its layer-normalization gain and layer-normalization bias are held fixed. This is an exact statement even with positive layer-normalization epsilon. Write , let be the coordinate arithmetic mean, and define the coordinate variance . For any scalar , we haveConsequently , so both the numerator and denominator of layer normalization are unchanged. Applying the same coordinatewise layer-normalization gain and layer-normalization bias preserves the equality:The positive layer-normalization epsilon is added to the coordinate variance before taking the square root.[ref]
The centering matrix makes the geometry explicit: and . Thus the common-offset direction lies in the kernel of a linear map represented by . For the normalized core , take and . Its coordinate arithmetic mean is 2 and its coordinate variance is , giving . The vector has exactly the same normalized core. An unequal coordinate shift need not be removed: instead gives .
This identifies a precise redundancy in a neural network. If the vector before layer normalization is an affine map , adding to its bias leaves the normalized result unchanged for every . A shift of the raw input by a vector produces , which need not be a common coordinate shift. The weight re-centering calculation in Layer Normalization by Jimmy Lei Ba and others uses the related transformation : its extra contribution is , which normalization removes separately for each input.[ref]
The positive constant in layer normalization regularizes division by the coordinate standard deviation. For coordinates, write , and . The normalized core and the full output areHere is the Hadamard product, and are fixed when studying the dependence on . This placement of , the divisor in the coordinate variance, and the elementwise layer-normalization gain and layer-normalization bias define the stabilized convention used here.[ref]
LayerNorm in the PyTorch documentation. Equation; correction=0; Parameters/eps and elementwise_affine
If all coordinates of are equal, then and : positive makes the normalized core well defined and equal to 0, so the full output is .Positive also changes the normalization away from constant inputs. The arithmetic mean of the normalized core is 0, but its normalized coordinate variance in layer normalization isThus it approaches 1 when is large, equals when , and approaches 0 when approaches 0. This formula describes the normalized core; learned, unequal coordinate gains or biases can change the coordinate arithmetic mean and variance of the full output. For , changing from to changes the core from to .
Although layer normalization is invariant under a common input shift, a fixed positive prevents exact positive scaling invariance on a nonconstant input. For ,For and fixed , this equals only when . With , the normalized core is exactly invariant for every wherever . The unstabilized scaling argument in Layer Normalization by Jimmy Lei Ba and others therefore needs this qualification when used for the stabilized formula.[ref]
Layer Normalization by Jimmy Lei Ba and others. §3, equation 3, and §5.1, equations 6–7: normalization statistics and scaling analysis
The same constant controls layer-normalization sensitivity. With the centering matrix , we have , and . Taking a derivative gives the layer-normalization Jacobian:The common-offset vector is an eigenvector with eigenvalue . For , the radial direction has eigenvalue ; a vector orthogonal to both and has eigenvalue . At a constant input, the Jacobian matrix is . These formulas give the operator norm bound for the Euclidean norm. Integrating this derivative along a line segment proves Lipschitz continuity of the normalized core with constant . The bound for the full output is multiplied by , the operator norm of the diagonal matrix of its layer-normalization gain. For , the core bound is attained in centered directions at a constant input: smaller permits larger local amplification near zero coordinate variance.
For the input family , the third coordinate of the normalized core is , with derivative . The dashed lines mark ; the forward response approaches these values for large positive or negative .
Original layer-normalization response and sensitivity for ; unit gains and zero biases.
Details. Layer-normalization sensitivity measures how strongly changes in an input can alter its normalized output. For the core and the Euclidean norm, its local first-order amplification is the operator norm . The derivation in layer-normalization epsilon gives the uniform boundIntegrating the derivative bound yields the corresponding global Lipschitz continuity bound. For at least two coordinates, the constant is attained locally in centered directions at constant inputs; it is a worst-case bound, not the amplification at every input.
An original finite perturbation check starts at and adds . The core at is zero. With , the norm ratio isclose to the derivative bound . Keeping the same perturbation but taking gives approximately , with bound . This probes the near-constant-input regime, where the coordinate variance is small compared with epsilon.
For fixed learned gains, the full output has bound ; a fixed layer-normalization bias does not change input differences. The layer-normalization gain can therefore amplify or suppress the core response. These are properties of this layer in a specified norm. They do not by themselves bound a complete network, whose other operations and composition also matter. The explicit matrix example in layer-normalization Jacobian illustrates why actual amplification can be smaller than the uniform bound.
The normalized coordinate variance in layer normalization is the variance across coordinates of the normalized core, with divisor equal to the number of coordinates. This is not a variance across training cases. If the input's centered coordinate variance is and layer-normalization epsilon is , the core has zero coordinate mean and varianceThe calculation is given in layer-normalization epsilon. The divisor convention agrees with the implementation's correction-zero variance.[ref]
An original inverse calculation asks how large must be to attain a desired core variance . Solving the displayed relation givesFor chosen and target , we need . The two-coordinate input has that variance and normalized core , whose variance is exactly . Reaching instead requires . With fixed positive epsilon, exact unit core variance is never attained at finite .
The restriction applies to the core, before the learned affine transformation. For the first example, uniform layer-normalization gain and zero layer-normalization bias produce coordinate variance . Unequal gains or biases can change both the mean and variance. A test that assumes the full output must always have unit variance would therefore reject valid layer-normalization computations.
A sequence model built from stacked transformer blocks, using self-attention to mix information between positions and positionwise feedforward neural networks to transform their representations. Positional encoding supplies sequence-order information. An autoregressive decoder uses causal self-attention; generation remains sequential even when training computations over known sequence positions are parallel.
Information representing sequence position or relative position, supplied to input representations or to attention scores. It can be fixed or learned. Without order information or a position-dependent mask, a self-attention layer using shared projections treats a simultaneous permutation of sequence positions equivariantly.
An attention operation in which queries, keys, and values are projections of one sequence's representations. At each position, learned similarities between its query and permitted keys determine a weighted sum of the corresponding values. Scaled dot-product attention and multi-head attention are standard implementations; causal self-attention restricts which positions can be accessed.
Self-attention whose output at sequence position may depend only on positions at or before . In a score matrix, set forbidden future-position scores to negative infinity before applying the softmax function; the corresponding weights become zero. This permits parallel computation over a known training sequence without allowing future tokens to influence earlier predictions.
Several independently learned query, key, and value projections apply scaled dot-product attention in parallel. Concatenating their outputs and applying a learned output projection allows different heads to mix sequence information using different learned representations.
With query and key dimension , form the score matrix , apply the softmax function row by row, and multiply by the values . If query and key coordinates have independent unit variance, their dot product has variance ; division by keeps that score scale of order one. Optional additive masks exclude forbidden keys before the softmax function.
A standard transformer block combines multi-head attention with a positionwise feedforward neural network, wrapping each sublayer in a residual connection and layer normalization. An encoder-decoder transformer's decoder also has a cross-attention sublayer. Pre-normalization and post-normalization variants differ in where layer normalization occurs relative to the sublayer and residual connection.
The learned additive constant in a unit preactivation, . It can be represented by weight on a constant input .
Reuse of one learnable parameter in multiple computational positions. In a convolution this reduces parameter count and imposes translation equivariance away from boundary effects.
A convolutional neural network uses local connections and weight sharing across input positions. Each learned filter detects the same local feature at multiple positions; successive activation functions and layers combine those features. Shared filters impose translation equivariance away from boundary and sampling effects, while a pooling layer can reduce spatial size.
For a standard dense-channel two-dimensional convolution with a by kernel, input channels and output channels, the parameter count including one bias per output channel isIt is independent of the image's spatial dimensions. For example, a three-by-three convolution from three channels to sixteen channels has parameters. Grouped or depthwise convolutions use different connectivity and therefore different counts.
A neural network receptive field describes which input positions can influence a specified output unit through the network's computational connections. A local convolutional layer uses only a small input region for each output, but successive layers can combine information from a larger region. This dependence is relative to a chosen input layer; an immediate previous-layer neighborhood and the corresponding original-input region have different sizes.[ref]
Deep Learning by Ian Goodfellow and others. Chapter 9, §9.2, sparse interactions and Figure 9.4, growth of receptive fields in deeper layers
For an own one-dimensional example, use two kernel-size-three convolutional layers, with convolution stride one, no padding and no convolution dilation. Intermediate units , and depend on input sets , and respectively. The first output of the second layer combines these three units, so its possible original-input dependency isTwo size-three filters therefore give a size-five receptive region, not size nine.
A recurrence tracks the geometry of an undilated serial network. Let be the span of the receptive region in original-input positions and the original-input index separation between adjacent layer- outputs. With kernel size , stride and initial values ,The last contributing previous-layer unit lies input positions beyond the first, which proves the span increment. This derivation assumes the stated local serial connectivity, no padding and no dilation.
If the first size-three layer instead has stride two, then and . A second size-three, stride-one layer has : its three input supports are , and . Their union reaches from zero through six. For other sampling choices, a span can include gaps, so span and number of contributing positions need not agree.
This is a structural dependency calculation. Zero weights or the current behavior of an activation function can suppress an influence that the architecture permits; the calculation does not measure how strongly each position affects a particular output. A unit-stride pointwise convolution mixes neural network channels at the same location and does not enlarge this spatial region. The distinction helps explain why many channels alone do not guarantee access to distant input context.
A neural network feature map records a network's responses across positions in its input or an intermediate grid. In a convolutional neural network, one common convention calls each output neural network channel a feature map; several such maps are stacked to form the layer's output. State whether the phrase denotes one channel or the collection, since both usages occur.[ref]
Deep Learning by Ian Goodfellow and others. Chapter 9, §9.1, convolution input/kernel/output terminology; §9.5, multiple channels
[ref]Conv2d in the PyTorch documentation. Opening equation and Shape, output-channel and spatial dimensions
For an own example, use the single-channel gridApply a two-by-two local averaging filter without padding and with convolution stride one. Its output map isA second filter subtracting each patch's left column from its right column givesFor example, its upper-left response is . The two maps describe different local properties of the same input.
Stacking and gives an output with two neural network channels, each on a two-by-two grid: values in channel-height-width order. The channel index identifies which response rule was used; it is distinct from either spatial index. An activation function can then transform those values before another convolutional layer processes them.
The hand-chosen filters make the example interpretable, but learned maps need not correspond to a human-named object or property. Their entries are numerical responses determined jointly by the input, weights and preceding computation. A neural network feature map also need not have the same spatial dimensions as its input: patch size, convolution stride and padding affect the grid. Keeping the channel and spatial axes separate helps interpret both the computation and its dimensions.
A neural network channel indexes a component or response type at each position of a neural network's data grid. In a two-dimensional convolutional neural network, the channel axis is distinct from the two spatial axes. For example, an image represented with the RGB color model has red, green and blue input channels, while an intermediate neural network feature map can have many learned response channels.[ref]
Conv2d in the PyTorch documentation. Opening equation, input/output channel counts and spatial dimensions
The arrangement of axes must be stated. In the documented convention , counts examples, channels, rows and columns. Thus two three-channel images, each four pixels high and five pixels wide, have shape and containscalar entries. Changing the number of examples does not change the number of channels in each example.[ref]
Conv2d in the PyTorch documentation. Shape, batched input convention
A dense convolutional layer can mix all input channels into each output channel. For the preceding input, use eight output channels, three-by-three filters, convolution stride one and no padding. The output shape iswith scalar entries. Its eight filters use weights, plus eight biases if enabled, giving parameters. The leading example count does not multiply this parameter count: the same weights process each example.[ref]
Conv2d in the PyTorch documentation. Opening channel-summation equation; Shape; Variables, dense weight and bias dimensions with groups=1
The eight output channels are not eight new primary colors. Their values are determined by learned combinations of the preceding channels and spatial neighborhoods. Individual channels can be useful for interpretation, but a channel's index does not by itself identify a human-named feature or make its response a probability.
A pointwise convolution makes the channel operation especially clear: at every spatial point it maps one channel vector to another using the same matrix of weights. By changing that matrix, it can reduce or increase the channel count while preserving the grid dimensions under unit-stride, unpadded conditions. Keeping channel, spatial and example axes separate prevents both shape errors and misleading interpretations.
A convolutional layer applies shared local filters across an input grid to produce output neural network channels. Each filter combines the input channels and nearby positions, with the same learned weights reused at different output positions. This weight sharing distinguishes it from assigning unrelated weights to every grid location.[ref]
Deep Learning by Ian Goodfellow and others. Chapter 9, §9.2, sparse interactions and parameter sharing
For real-valued input , dense channel connectivity, no padding and convolution stride one, write the affine output asHere selects the output channel, an input channel, the filter weights and a neural network bias. The spatial indices stay in range. This unflipped-filter formula is the cross-correlation convention used by the Conv2d implementation, despite its convolution name. Mathematical discrete convolution reverses the kernel's displacement indices; state the convention when comparing formulas.[ref]
Conv2d in the PyTorch documentation. Opening equation, valid two-dimensional cross-correlation and channel summation
For one input channel, takeThe first patch gives . Applying the same weights everywhere givesA following rectified linear unit produces . The affine filter operation and the subsequent activation function are separate steps, although an architectural description sometimes groups them together.
For an input grid in this unpadded, unit-stride case, the output dimensions are . There are weights for each output channel and one bias, so the total parameter count isIt does not grow with or ; the number of filter applications does.[ref]
The neural network receptive field identifies which input positions can influence an output. Local filters restrict that dependency, while successive layers can combine information from a larger region. Convolution stride and zero padding alter the spatial sampling and boundary behavior; the explicit formulas above assume neither subsampling nor padding.
Convolution dilation specifies the spacing between neighboring kernel sample points in a convolutional layer. Dilation one samples adjacent positions; larger dilation separates those positions while keeping the filter's learned coefficient count fixed. Convolution stride instead controls the spacing between successive filter origins.[ref]
Conv2d in the PyTorch documentation. Opening parameter descriptions; Parameters, dilation and stride
For an own real one-dimensional example, takeand coefficients , with stride one, no padding and no bias. Use the unflipped cross-correlation convention. Dilation one sums three adjacent values and gives . Dilation two instead uses offsets :The second filter evaluates a wider input span while still using three coefficients.
For sampled coefficients separated by positions, the first-to-last displacement is . Including the first position gives the effective convolution kernel sizeThus spans five positions. At each origin only three of those five positions are sampled directly.
The same linear operation can be represented by a dense width-five kernel . The inserted zeros are fixed structure, not additional trainable coefficients. Dilation changes the footprint without making the original three-parameter filter a general five-parameter one.[ref]
Conv2d in the PyTorch documentation. Variables, weight shape depends on kernel dimensions and channel connectivity
For input length , symmetric zero padding and stride , the usual per-axis size formula becomeswhen the padded input accommodates the footprint. The example gives outputs. The floor function counts origins whose final sample remains in range.[ref]
Dilation can enlarge a unit's spatial neural network receptive field without evaluating every intervening input position. Whether later layers fill those gaps depends on the architecture. A wider span alone does not establish greater numerical influence at every position or better performance on a learning task.
The effective convolution kernel size is the bounding extent of a dilated convolution kernel along a spatial axis. For sampled coefficients with convolution dilation , their offsets are . The first-to-last displacement is , so including the first position givesThis extent determines the kernel footprint used in spatial shape calculations; it is not generally the number of coefficients.[ref]
For a two-dimensional example, choose a sampled kernel shape with dilation . Its row offsets are and column offsets are . The bounding shape is thereforeThere are six sampled spatial positions inside a twenty-position bounding box. Fourteen intermediate positions are absent from the sampling pattern.
With three input neural network channels and four output channels, ordinary dense channel connectivity usesweights and optionally four biases, giving parameters. A general dense five-by-four kernel with the same channel counts would have weights. Representing the dilated operation that way would require of them to be fixed zeros, rather than independently learned parameters.[ref]
For an unpadded -by- input and convolution stride one, the output grid isMore generally, for one axis with symmetric zero padding and stride ,when the padded input accommodates the footprint. The floor function counts admissible filter origins.[ref]
The effective size is a geometric quantity for one layer. The complete neural network receptive field through several layers additionally depends on their kernels, strides and connections. Likewise, changing stride moves the spacing of origins; changing dilation changes the footprint at each origin. Keeping bounding extent, sampled-position count and learned-parameter count separate avoids confusing three different sizes.
The convolution stride specifies how far the filter's origin advances between neighboring output positions of a convolutional layer. It controls which spatial positions are evaluated. A larger stride usually produces a smaller output grid without changing the number of coefficients in each filter.[ref]
For a real one-dimensional example, take the inputand a size-three all-ones filter, no bias and no padding. Using the unflipped cross-correlation convention, stride one evaluates windows beginning at indices and givesStride two evaluates windows beginning at indices , givingThe second result keeps every second origin from this first grid; it still combines three input values for each retained origin.
For an undilated length- input and length- filter, no padding and stride , a zero-indexed output uses input indices through . Requiring its last index not to exceed gives . Counting the admissible nonnegative integers therefore giveswhen and is a positive integer. The floor function is essential when the last candidate origin would extend beyond the input.
With symmetric zero padding of positions per side and convolution dilation , the corresponding standard shape expression isHere dilation changes the spacing of samples within a filter footprint; stride changes the spacing between filter origins. The two parameters have different roles.[ref]
Conv2d in the PyTorch documentation. Parameters, stride/padding/dilation; Shape, each spatial-axis formula
For two-dimensional data, specify a stride for each spatial axis; unequal strides need not reduce height and width by the same amount. The weights of the filter remain shared across the visited positions. Stride also changes how neighboring outputs' neural network receptive fields are spaced in the original input, so it affects more than just a displayed array size.
A pointwise convolution uses a spatial kernel of size one to combine neural network channels independently at each spatial position. For a two-dimensional input this is a one-by-one convolutional layer. In the ordinary dense-channel, unit-stride case, the same affine map acts on the channel vector at every grid point.[ref]
Conv2d in the PyTorch documentation. Opening equation and kernel_size/stride parameters, specialized to kernel size one and groups=1
Let be the channel vector at position . With weight matrix and neural network bias vector , the output isThis is matrix multiplication across channels, not an average of neighboring spatial positions. The same and are reused throughout the grid.
For an example without biases, takeAt a point with input the output is . At another point with input it is . A three-channel neural network feature map has become a two-channel map without mixing the two positions.
There are weights, plus optional biases. Thus three input and two output channels require six weights, or eight parameters including biases. A dense three-by-three filter with the same channel counts requires weights, or fifty-six parameters with biases. This comparison counts parameters for the stated connectivity; it does not claim that the two layers compute equivalent functions.
Channel reduction can make a later spatial convolutional layer cheaper. The original Inception uses one-by-one reductions before some larger filters. A pointwise operation can also increase the channel count; size one refers to its spatial footprint, not to the number of channels.[ref]
Going Deeper with Convolutions by Christian Szegedy and others. §4 and Fig. 2, one-by-one dimension-reduction branches
With no intervening spatial operation, pointwise layers and pointwise activation functions alone do not enlarge the spatial neural network receptive field.Inception is a family of convolutional neural network architectures built around modules with parallel processing branches. An early module combines several convolution sizes and a pooling layer, then joins their outputs along the channel dimension. Pointwise convolution can reduce channel counts before more expensive spatial operations.[ref]
Going Deeper with Convolutions by Christian Szegedy and others. §4 and Fig. 2, parallel branches and dimensionality reduction
For a stipulated shape example, let every branch produce a grid, with output channel counts , , and . Joining channels gives a output becauseThe equal spatial grid sizes are an assumption ensured by the branch design. Channel joining does not add corresponding values into one channel; it retains the distinct branch outputs as separate channels of the combined neural network feature map.
A cost example explains the reduction branch. Ignoring biases, a dense three-by-three convolutional layer from input channels to output channels hasweights. Reducing first from to channels with a one-by-one pointwise convolution, then applying the three-by-three layer, usesweights. This own example isolates channel dimensions; it is not a reported layer configuration or a claim that the two computations represent identical functions.
The original paper presents this design in the GoogLeNet network and evaluates image classification and detection. Later Rethinking the Inception Architecture for Computer Vision by Christian Szegedy and others develops additional factorization and training choices. The family name therefore does not identify one immutable list of layers or one universal performance result.[ref]
Going Deeper with Convolutions by Christian Szegedy and others. Abstract; §§4–5, modules and network
[ref]A network layer aggregating nearby activations, for example by a maximum or mean. Pooling can reduce spatial size but does not by itself guarantee arbitrary translation invariance.
A binary threshold unit outputs one when its weighted input reaches its threshold and zero otherwise. Its hard threshold is not differentiable, so ordinary backpropagation cannot directly train the exact threshold model. Smooth activation functions can approximate its computation.
An activation function converts a unit's weighted input to its output. A sigmoid function, hyperbolic tangent or rectifier can give nonlinear features. Replacing all hidden activation functions by the identity collapses consecutive affine layers into a single affine map, removing the representational benefit of those hidden layers.
An associative memory retrieves a stored pattern from a related cue. An incomplete cue supplies only some coordinates; a corrupted cue supplies some wrong coordinates. A Hopfield network implements retrieval by making intended patterns stable states with surrounding basins of attraction. This turns correction into a collective computation: no unit needs to know the entire desired answer. A cue outside the appropriate basin of attraction can retrieve another pattern or an unintended stable state.
Reinstatement of a stored representation from an incomplete or degraded cue. Recurrent autoassociative memory provides one mechanism; its success depends on the cue entering the correct basin of attraction. Partial-cue deficits after CA3-targeted NMDA receptor deletion support a hippocampal role without identifying a unique weight-update rule.[ref]
Requirement for hippocampal CA3 NMDA receptors in associative memory recall by Kazu Nakazawa and others. Abstract; pp. 211–218, adult CA3-restricted deletion and full-cue versus partial-cue recall
A transformation that makes representations of similar inputs less overlapping, helping reduce interference between stored events. It must retain enough information for useful downstream learning and retrieval. The dentate gyrus is a proposed substrate, with quantitative input–output evidence from spatial cue-conflict experiments.[ref]
CA3 retrieves coherent representations from degraded input: direct evidence for CA3 pattern completion and dentate gyrus pattern separation by Joshua P. Neunuebel and others. Abstract; simultaneous DG/CA3 recordings during local/global cue conflict
A memory retrieves a stored pattern from a partial or corrupted version of that pattern. A recurrent Hopfield network supplies a precise idealization through stored attractors and their basins of attraction. Retrieval can fail through interference, ambiguous cues or spurious stable states.
A learned map retrieves an associated output pattern that need not equal its input cue. With normalized cue vectors and targets , Hebbian learning gives . For orthonormal cues, ; taking the matrix product proves exact retrieval. Nonorthogonal cues add interference . Additional context is required if one identical cue should select different outputs on different occasions.
A recurrent network with symmetric interactions and an energy function. In the binary version, units take values , self-couplings are zero, and asynchronous threshold updates can retrieve stored patterns from incomplete or corrupted cues. Fixed points are local energy minima, which need not be the intended memories or global minima.
For a symmetric matrix of couplings with , define the energy landscapeThe factor removes double counting. The local input is . Choosing to agree with lowers this energy; this mathematical energy need not be a conserved physical quantity. Its pairwise form connects the model to the Ising model; competing couplings also motivate the comparison with a spin glass. Here retrieval seeks a useful nearby local minimum, so reaching the global minimum is not the goal.
John Hopfield's 1982 computer study stored random binary strings in neural networks of 30 and 100 units. Couplings were prepared from the stored patterns; asynchronous updates supplied the computational apparatus. Starting at each nominal memory, the readout counted Hamming distances after settling as storage load varied. Corrupted starting patterns separately tested recovery. Varying the load and cue damage exposed interference between memories. These simulations supported collective retrieval, not a measurement of biological memory capacity.[ref]
Neural networks and physical systems with emergent collective computational abilities by John Joseph Hopfield. 1982, pp. 2555–2557, storage Eq. 2, Fig. 2 and corrupted-start tests
For symmetric zero-diagonal weights and zero thresholds, update one binary unit to the sign of its current field, retaining it at a zero field. The displayed energy change is negative on every actual flip. There are finitely many states, so a fair asynchronous update schedule eventually reaches a fixed point that is a minimum against single-unit flips. Synchronous updates can instead cycle, and local minima need not be global minima.
To obtain the displayed identity, subtract the two energies. Terms not involving cancel, and symmetry combines the two copies of each pair. With thresholds included the result is . The zero-threshold expression above is its specialization. At , keeping the old state rules out motion along equal-energy states. Finiteness then excludes infinitely many strict decreases, while fairness ensures that an unstable unit cannot be ignored forever. A local minimum here means no single flip lowers energy; equality directions can remain.
The asynchronous condition matters even for two units: with and zero thresholds, simultaneous updates alternate and forever. Either single-unit update instead reaches an aligned stable state.
For binary units and desired patterns , use these symmetric weights and set . For one pattern, the field at that pattern is , so it is stable. Several patterns add cross-talk terms; storage by this rule alone does not guarantee stability of every arbitrary collection of patterns.
Writing givesfor stored patterns. The subtraction removes the forbidden self-couplings. It makes explicit how the desired association competes with all other stored patterns. An unintended stable state can therefore arise even though every update obeys asynchronous Hopfield energy descent.
Store only with , zero thresholds, and Hebbian memory weights for a Hopfield network. If bits differ from , their Hamming distance is and . Squaring this sum and subtracting the diagonal terms yields the displayed energy. Thus gives .
For the cue , the first unit has input and flips to . The second then has and flips to , completing recall. The energy drops . Every cue with at most two wrong bits is corrected under a fair asynchronous schedule: a wrong bit sees the correct majority among the other four, while a correct bit either sees agreement or retains its value at a tie. The opposite pattern is also stored implicitly, so cues with at least three errors retrieve it. This is a limitation of this symmetric one-pattern construction.
An exact five-unit memory landscape and correction of two wrong bits
. Each point represents every state at the indicated Hamming distance; multiplicities count the states. Arrows follow two actual updates of the illustrated cue under asynchronous Hopfield energy descent. This is an original finite calculation. Details.A Boltzmann machine is a stochastic neural network that learns a probability distribution specified by pairwise energies. To compare it directly with a Hopfield network, use the bipolar energy . Here controls the preference for low energy, and the partition function normalizes all states. In a computational model, is an algorithmic inverse temperature; interpreting it as additionally requires physical energy units.
A random single-unit Gibbs sampling update has conditional probabilityIndeed, the two possible energies differ by ; their normalized Boltzmann weights give this logistic function. Random selection of one unit at a time satisfies detailed balance. For finite weights and finite positive , all conditional probabilities lie strictly between zero and one, so the finite Markov chain can reach every state and can remain in place. Its unique stationary distribution is . A short run need not yet sample that distribution accurately.
As , a nonzero field selects its sign, approaching asynchronous Hopfield energy descent. At zero field the stochastic rule remains a fair coin, whereas the deterministic convention above retains the old value. At finite inverse temperature, uphill moves permit exploration beyond one local minimum. Recall and learning are different operations: sampling changes the units at fixed weights; learning changes the weights to fit the training data.
Split the units into visible units , whose patterns occur in the training data, and hidden units . Let be the empirical probability distribution and maximize the average log-likelihood , where . The positive phase clamps to data and averages over ; the negative phase releases all units and averages over . The displayed difference uses these two expectations. When both units are visible, the positive pair product is supplied directly by the data.
For a proof, write . Differentiating each finite sum gives, respectively, and . Since , subtraction proves the rule. Similarly . A small positive step along these gradients increases log-likelihood. The negative term suppresses associations overproduced by the model; strengthening observed pairs alone misses this correction. The identity requires equilibrium expectations; estimates from insufficiently mixed sampling can give a biased update.
A visible unit represents an observed coordinate of the data. Clamping it means holding that coordinate fixed while other units update. In a Boltzmann machine, hidden units are unobserved coordinates summed out to obtain the visible marginal distribution.
Take two visible bipolar units, no hidden units, zero thresholds, , and . As original training data, assign probabilities each to and and each to and . The data pair product averages to . Enumeration of all four states gives two weights and two , hence the partition function andStarting at , the positive-minus-negative difference is . A gradient ascent step of size gives . Each aligned state now has probability and each opposed state , bringing the model toward the data. The log-likelihood increases from to . Solving gives , which reproduces the data exactly. Since , this is the unique maximum. These are exact enumerations and their decimal evaluations, with no sampling or laboratory measurements.
Exact probabilities and positive-minus-negative learning for two visible units
. Left: data and model probabilities before and after one gradient ascent step. Right: the data pair-product average and the model average determine the log-likelihood derivative; their intersection gives the optimal coupling. Details.David H. Ackley, Geoffrey Hinton and Terrence J. Sejnowski tested their 1985 algorithm on a simulated 4–2–4 encoder. Two four-unit visible groups communicated through two hidden units, with no direct connections between the groups. Preparation set weights to zero and supplied corresponding one-active-unit patterns. Noisy clamping and annealed settling generated pair-coactivation readouts, compared with freely running readouts to choose weight changes. Learned hidden codes were the outcome. Equal sampling effort in clamped and free conditions supplied the comparison; noise limited weight growth. Finite settling was assumed to reach equilibrium, limiting the evidence for exact likelihood learning.[ref]
A feedforward neural network composes layers without directed cycles, passing each layer's activations only to later layers.
A layered neural network with affine maps and activation functions, usually with dense connections between successive layers. A dense layer with inputs and outputs has parameters including biases.
Let be the number of active inputs. Four hidden units , , detect successively larger counts. A binary threshold unit with weights on these features and threshold returns one precisely for . Each hidden input weight is one. This computes parity with a single hidden layer, but representability does not guarantee easy learning by backpropagation.
Backpropagation applies the chain rule from a neural network's output toward its input to compute the gradient of a loss with respect to every parameter.
Apply the chain rule to a recurrent network unrolled over its input sequence, adding contributions to parameters reused at multiple time steps. Products of state Jacobians convey effects from earlier states to later losses. This can compute exact gradients for the chosen finite unrolling, while physiological availability of the same history and error signals is a separate question.
A learning scheme replacing a transposed forward-weight matrix in the teaching signal with a separate fixed random matrix. Simulations show that adaptation of the forward weights can make this feedback useful on tested tasks. It need not equal the exact loss gradient, and successful simulations alone do not establish the mechanism in the brain.[ref]
Random synaptic feedback weights support error backpropagation for deep learning by Timothy P. Lillicrap and others. Results, Figure 1 and Figure 2; Discussion: random feedback, learning performance and biological limitations
Exact backpropagation computes hidden teaching signals using the transpose of the current forward weight matrix. Explaining how a biological feedback pathway could know or maintain those weights is the weight transport problem. Useful approximate error correction need not satisfy exact reciprocal weight equality.[ref]
Random synaptic feedback weights support error backpropagation for deep learning by Timothy P. Lillicrap and others. Results, Figure 1 and Figure 2; Discussion: random feedback, learning performance and biological limitations
For squared loss , let and . The chain rule gives and . A gradient descent step of size uses and , with every derivative evaluated at the same pre-update weights.
For hidden activations and class probabilities , a one-hot label has log-likelihood . Put and . ThenThese follow from the chain rule and give single-observation stochastic gradient descent updates for the negative log-likelihood.
A sigmoid function has an S-shaped graph, typically increasing between finite lower and upper limits. The standard logistic function, often called the sigmoid in neural networks, isThe hyperbolic tangent is another sigmoid: . Thus sigmoid names a broader family than the logistic formula alone. Logistic outputs lie in and can represent a binary classification probability, but using this activation function alone does not ensure that the fitted probabilities are calibrated. Its derivative tends to zero in both tails, one mechanism behind the vanishing gradient problem.
The standard logistic function maps a log odds to probability . More generally, its translated and scaled form is .
If , then for every , replacing by and by leaves each exponent unchanged. The same choices therefore cannot identify both an unrestricted value scale and inverse temperature. Fixing a value scale or adding independent measurements is needed to break this equivalence.
Adding the same scalar-valued function of the input to every class logit leaves all softmax probabilities unchanged. A reference-class constraint removes this common-shift non-identifiability.
For one-hot label and predicted class probabilities , categorical cross-entropy is , the negative categorical log-likelihood.
Articles by others on the same topic
A neural network is a computational model inspired by the way biological neural networks in the human brain process information. It consists of interconnected groups of artificial neurons (also called nodes) that work together to process data and recognize patterns. Neural networks are a key component of machine learning and deep learning technologies.


