← Mathematical compendium

Published equation contexts

r=S(q−Z)r = S \left( q - Z \right)

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

A model trained in 32-bit floating point does not run on a microcontroller with a few hundred kilobytes of RAM and no floating-point unit worth using for anything but the occasional scalar. The standard fix is quantization: representing weights and activations as low-bit integers, most commonly 8-bit, and executing the forward pass using integer arithmetic end to end. The scheme that made this practical for commodity hardware is an affine mapping between a real value and its stored integer, r=S(q−Z)r = S \left( q - Z \right). where r is the real-valued number, q is the stored integer, S > 0 is a scale factor, and Z is an integer zero-point chosen so that real zero maps exactly onto a representable integer…

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 \left( q - Z \right),

Equation 1 · Edge AI & Electronics

Edge AI Electronics and Sensor Systems in Practice: Quantization, Power Budgets, and Sensor Front Ends

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

A model trained in 32-bit floating point does not run on a microcontroller with a few hundred kilobytes of RAM and no floating-point unit worth using for anything but the occasional scalar. The standard fix is quantization: representing weights and activations as low-bit integers, most commonly 8-bit, and executing the forward pass using integer arithmetic end to end. The scheme that made this practical for commodity hardware is an affine mapping between a real value and its stored integer, r=S(q−Z)r = S \left( q - Z \right). where r is the real-valued number, q is the stored integer, S > 0 is a scale factor, and Z is an integer zero-point chosen so that real zero maps exactly onto a representable integer…

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 →