# US 2022/0044109 A1 · Quantization-aware training of quantized neural networks

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0044109 A1
- Document ID: US20220044109A1
- Status: Published application
- Kind: A1
- Application number: 16/987,163
- Filed: 2020-08-06
- Published: 2022-02-10
- Earliest claimed: 2020-08-06
- Applicants: Waymo LLC
- Inventors: Paul Donnelly
- Web page: https://patentgrep.com/patent/US20220044109A1

## CPC

- G06N 3/063: using electronic means
- G06N 3/08: Learning methods
- G06N 3/04: Architecture, e.g. interconnection topology
- G06N 3/0464: Convolutional networks [CNN, ConvNet]
- G06N 3/0495: Quantised networks; Sparse networks; Compressed networks
- G06N 5/01: Dynamic search techniques; Heuristics; Dynamic trees; Branch-and-bound
- G06N 5/046: Forward inferencing; Production systems
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

Methods, systems, and apparatus, including computer programs encoded on computer storage media, for training a quantized neural network. One of the methods includes, for each of a plurality of neural network layers and at each of a plurality of training time steps: receiving an input tensor for the neural network layer; processing the input tensor using the neural network layer to generate an output tensor, wherein the output tensor has a first precision; obtaining a current quantization range for output tensors of the neural network layer; processing the output tensor using the current quantization range to generate a quantized output tensor that has a second precision that is lower than the first precision; determining an error between the output tensor and the quantized output tensor; and determining an update to the quantization range using the determined error.

## Claims

### Claim 1

A method of training a quantized neural network comprising, for each of a plurality of neural network layers and at each of a plurality of training time steps:
receiving an input tensor for the neural network layer;
processing the input tensor using the neural network layer to generate an output tensor, wherein the output tensor has a first precision;
obtaining a current quantization range for output tensors of the neural network layer;
processing the output tensor using the current quantization range to generate a quantized output tensor that has a second precision that is lower than the first precision;
determining an error between the output tensor and the quantized output tensor; and
determining an update to the quantization range using the determined error.

### Claim 2 (depends on 1)

The method of claim 1, wherein the quantization range for output tensors of the neural network layer is defined by a minimum scalar value and a maximum scalar value.

### Claim 3 (depends on 1)

The method of claim 1, wherein the quantization range for output tensors of the neural network layer is defined by i) a minimum tensor having a same number of elements as the output tensors of the neural network layer and ii) a maximum tensor having a same number of elements as the output tensors of the neural network layer.

### Claim 4 (depends on 1)

The method of claim 1, wherein the quantization range for output tensors of the neural network layer is defined by i) a minimum tensor having a number of elements equal to a number of channels of the output tensors and ii) a maximum tensor having a number of elements equal to the number of channels of the output tensors.

### Claim 5 (depends on 1)

The method of claim 1, wherein determining an error between the output tensor and the quantized output tensor comprises determining, for each element of the output tensor, an element error between the element of the output tensor and the corresponding element of the quantized output tensor.

### Claim 6 (depends on 5)

The method of claim 5, wherein determining an element error of an element of the output tensor comprises:
determining whether the element is below the quantization range, above the quantization range, or in the quantization range;
if determining that the element is below the quantization range, determining the element error to be a difference between the element and a minimum value of the quantization range;
if determining that the element is above the quantization range, determining the element error to be difference between the element and a maximum value of the quantization range;
if determining that the element is in the quantization range, determining the element error to be an average element error for elements evenly distributed in the quantization range.

### Claim 7 (depends on 1)

The method of claim 1, wherein processing the input tensor using the neural network layer comprises:
obtaining a weight tensor for the neural network layer, wherein the weight tensor has the first precision;
determining a minimum weight value and a maximum weight value for elements of the weight tensor;
processing the weight tensor using the minimum weight value and the maximum weight value to generate a quantized weight tensor that has the second precision;
processing the input tensor and the quantized weight tensor to generate the output tensor.

### Claim 8 (depends on 1)

The method of claim 1, wherein determining an update to the quantization range using the determined error comprises determining the update using gradient descent.

### Claim 9 (depends on 8)

The method of claim 8, wherein a learning rate for determining the update to the quantization range is proportional to a learning rate for determining an update to a weight tensor of the neural network layer.

### Claim 10 (depends on 8)

The method of claim 8, wherein a learning rate for determining the update to the quantization range is inversely proportional to a size of the input tensor for the neural network layer.

### Claim 11 (depends on 1)

The method of claim 1, wherein determining an update to the quantization range using the determined error comprises determining the update using exponential moving average smoothing.

### Claim 12

A system comprising one or more computers and one or more storage devices storing instructions that are operable, when executed by the one or more computers, to cause the one or more computers to perform operations for training a quantized neural network, the operations comprising, for each of a plurality of neural network layers and at each of a plurality of training time steps:
receiving an input tensor for the neural network layer;
processing the input tensor using the neural network layer to generate an output tensor, wherein the output tensor has a first precision;
obtaining a current quantization range for output tensors of the neural network layer;
processing the output tensor using the current quantization range to generate a quantized output tensor that has a second precision that is lower than the first precision;
determining an error between the output tensor and the quantized output tensor; and
determining an update to the quantization range using the determined error.

### Claim 13 (depends on 12)

The system of claim 12, wherein the quantization range for output tensors of the neural network layer is defined by a minimum scalar value and a maximum scalar value.

### Claim 14 (depends on 12)

The system of claim 12, wherein the quantization range for output tensors of the neural network layer is defined by i) a minimum tensor having a same number of elements as the output tensors of the neural network layer and ii) a maximum tensor having a same number of elements as the output tensors of the neural network layer.

### Claim 15 (depends on 12)

The system of claim 12, wherein the quantization range for output tensors of the neural network layer is defined by i) a minimum tensor having a number of elements equal to a number of channels of the output tensors and ii) a maximum tensor having a number of elements equal to the number of channels of the output tensors.

### Claim 16 (depends on 12)

The system of claim 12, wherein determining an error between the output tensor and the quantized output tensor comprises determining, for each element of the output tensor, an element error between the element of the output tensor and the corresponding element of the quantized output tensor.

### Claim 17

One or more non-transitory computer storage media encoded with computer program instructions that when executed by a plurality of computers cause the plurality of computers to perform operations for training a quantized neural network, the operations comprising, for each of a plurality of neural network layers and at each of a plurality of training time steps:
receiving an input tensor for the neural network layer;
processing the input tensor using the neural network layer to generate an output tensor, wherein the output tensor has a first precision;
obtaining a current quantization range for output tensors of the neural network layer;
processing the output tensor using the current quantization range to generate a quantized output tensor that has a second precision that is lower than the first precision;
determining an error between the output tensor and the quantized output tensor; and
determining an update to the quantization range using the determined error.

### Claim 18 (depends on 17)

The non-transitory computer storage media of claim 17, wherein the quantization range for output tensors of the neural network layer is defined by a minimum scalar value and a maximum scalar value.

### Claim 19 (depends on 17)

The non-transitory computer storage media of claim 17, wherein the quantization range for output tensors of the neural network layer is defined by i) a minimum tensor having a same number of elements as the output tensors of the neural network layer and ii) a maximum tensor having a same number of elements as the output tensors of the neural network layer.

### Claim 20 (depends on 17)

The non-transitory computer storage media of claim 17, wherein the quantization range for output tensors of the neural network layer is defined by i) a minimum tensor having a number of elements equal to a number of channels of the output tensors and ii) a maximum tensor having a number of elements equal to the number of channels of the output tensors.
