← Mathematical compendium

Published equation contexts

r=S (q−Z)r = S\,(q - Z)

A neural network may work with values such as −0.75, 0, or 1.25. Small devices can store a nearby integer code instead. This equation tells you which model value that code represents.

Why this formula appears here

The arithmetic-shrinking lever is quantization. A widely used scheme maps a real-valued weight or activation r onto a low-bit integer q through an affine relationship r=S (q−Z)r = S\,(q - Z). with a scale S and a zero-point Z chosen so that ordinary 8-bit integers can represent the values a trained network actually produces. The 2018 paper that formalized this scheme for mobile and embedded inference showed that training the network with this quantization in the loop, rather than quantizing a finished floating-point model after the fact, preserves accuracy far better, and that integer-only arithmetic — no floating-point unit required anywhere in the inference path — can be implemented…

Read the full article-specific guide →

Read the representative guide

rr

Real-valued model value

One numerical weight or activation as the model uses it. “Real-valued” means it belongs on the continuous number line: it can be negative, zero, fractional, or positive. In a computer it is stored with finite precision, so the stored float is only an approximation to a mathematical real number.

Read this term in its guide →
qq

Stored integer code

The whole-number code kept in the compact representation. For example, q = 14 is a code; it is not itself the model value 14. The allowed code range depends on the chosen integer format.

Read this term in its guide →
ZZ

Zero-point

The integer code that stands for the real value zero. If Z = 10, then q = 10 decodes to r = 0 exactly. It shifts the integer code range left or right relative to real zero.

Read this term in its guide →
q−Zq-Z

Offset from zero

Count how many integer steps q lies above or below the zero-point. A positive result gives a positive model value; a negative result gives a negative one.

Read this term in its guide →
SS

Scale or step size

A positive number saying how much one integer step is worth in the model’s units. If S = 0.25, moving q by 1 changes the decoded value by 0.25. A larger S covers more range with coarser spacing.

Read this term in its guide →
r=S(q−Z)r=S(q-Z)

Decoded value

Subtract Z from the stored code, then multiply by S. For q = 14, Z = 10, and S = 0.25, the code represents r = 0.25 × (14 − 10) = 1.00.

Read this term in its guide →

Why “real-valued” matters

A real number is a position on the number line. In this article, r is one weight or activation of a neural network before it is reduced to a small integer code. The original model may need values between whole numbers, such as 0.9 or −0.35. An integer code can only choose from separate steps. Quantization trades some precision for smaller storage and integer arithmetic.

Explore real numbers and floating-point values →

What is being shifted and scaled?

Z picks the integer code that means real zero. Subtracting it recenters the code: q − Z = 0 at the origin. S converts a one-code move into a change in the model value. Together they form an affine mapping: first shift, then scale.

Explore the zero-point →

What this equation leaves out

The formula describes one scalar value. Real neural networks contain arrays of weights and activations. Different arrays, and sometimes different channels, can use different scales. The integer range also depends on the implementation. Values outside the chosen range may be clipped.

How to interpret it

This is the decoding direction: integer code → represented model value. The original value might have been 0.9, while the nearest code decodes to 1.0, so quantization can introduce error. Encoding goes the other way: round r/S + Z to a permitted integer code and clamp it if necessary. The equals sign defines the value represented by q; it does not promise that every original real value survives exactly.

Sources in the representative guide

Published contexts (1)

A symbol can carry a different meaning in another article. Each occurrence keeps its own guide and term definitions.

r=S (q−Z),r = S\,(q - Z),

Equation 9 · Edge AI & Electronics

How Edge AI Electronics and Sensor Systems Actually Work

An integer code q represents a model value r: subtract the zero-point Z, then multiply by the step size S.

The arithmetic-shrinking lever is quantization. A widely used scheme maps a real-valued weight or activation r onto a low-bit integer q through an affine relationship r=S (q−Z)r = S\,(q - Z). with a scale S and a zero-point Z chosen so that ordinary 8-bit integers can represent the values a trained network actually produces. The 2018 paper that formalized this scheme for mobile and embedded inference showed that training the network with this quantization in the loop, rather than quantizing a finished floating-point model after the fact, preserves accuracy far better, and that integer-only arithmetic — no floating-point unit required anywhere in the inference path — can be implemented…

Meanings in this article

  • rr: One numerical weight or activation as the model uses it. “Real-valued” means it belongs on the continuous number line: it can be negative, zero, fractional, or positive. In a computer it is stored with finite precision, so the stored float is only an approximation to a mathematical real number.
  • qq: The whole-number code kept in the compact representation. For example, q = 14 is a code; it is not itself the model value 14. The allowed code range depends on the chosen integer format.
  • ZZ: The integer code that stands for the real value zero. If Z = 10, then q = 10 decodes to r = 0 exactly. It shifts the integer code range left or right relative to real zero.
  • q−Zq-Z: Count how many integer steps q lies above or below the zero-point. A positive result gives a positive model value; a negative result gives a negative one.
  • SS: A positive number saying how much one integer step is worth in the model’s units. If S = 0.25, moving q by 1 changes the decoded value by 0.25. A larger S covers more range with coarser spacing.
  • r=S(q−Z)r=S(q-Z): Subtract Z from the stored code, then multiply by S. For q = 14, Z = 10, and S = 0.25, the code represents r = 0.25 × (14 − 10) = 1.00.
Equation guide → · Article →