KR20200139071A - Method and apparatus for quantizing parameter in neural network - Google Patents

Method and apparatus for quantizing parameter in neural network Download PDF

Info

Publication number
KR20200139071A
KR20200139071A KR1020190104581A KR20190104581A KR20200139071A KR 20200139071 A KR20200139071 A KR 20200139071A KR 1020190104581 A KR1020190104581 A KR 1020190104581A KR 20190104581 A KR20190104581 A KR 20190104581A KR 20200139071 A KR20200139071 A KR 20200139071A
Authority
KR
South Korea
Prior art keywords
value
quantization
quantization value
neural network
parameter
Prior art date
Application number
KR1020190104581A
Other languages
Korean (ko)
Inventor
유형석
심현욱
이종은
Original Assignee
삼성전자주식회사
울산과학기술원
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 삼성전자주식회사, 울산과학기술원 filed Critical 삼성전자주식회사
Priority to US16/890,045 priority Critical patent/US11531893B2/en
Publication of KR20200139071A publication Critical patent/KR20200139071A/en
Priority to US17/987,079 priority patent/US20230085442A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology

Abstract

A method and device for quantizing a parameter in a neural network determine a first quantization value by performing log quantization on a parameter of the neural network, determine a second quantization value by performing log quantization on an error between a first dequantization value obtained by dequanziation for the first quantization value and the parameter, and quantize the parameter to a value that the first quantization value and the second quantization value are grouped.

Description

뉴럴 네트워크에서 파라미터를 양자화하는 방법 및 장치{Method and apparatus for quantizing parameter in neural network}A method and apparatus for quantizing a parameter in a neural network

본 개시는 뉴럴 네트워크에서 파라미터를 양자화하는 방법 및 장치에 관한다.The present disclosure relates to a method and apparatus for quantizing parameters in a neural network.

뉴럴 네트워크(neural network)는 생물학적 뇌를 모델링한 컴퓨터 과학적 아키텍쳐(computational architecture)를 참조한다. 최근 뉴럴 네트워크 기술이 발전함에 따라, 다양한 종류의 전자 시스템에서 뉴럴 네트워크 장치를 사용하여 입력 데이터를 분석하고 유효한 정보를 추출하는 연구가 활발히 진행되고 있다.Neural network refers to a computational architecture that models a biological brain. With the recent development of neural network technology, researches for analyzing input data and extracting valid information using neural network devices in various types of electronic systems have been actively conducted.

뉴럴 네트워크 장치는 복잡한 입력 데이터에 대한 많은 양의 연산을 필요로 한다. 뉴럴 네트워크 장치가 입력을 실시간으로 분석하고, 정보를 추출하기 위해서 뉴럴 네트워크 연산을 효율적으로 처리할 수 있는 기술이 요구된다. 특히, 스마트폰과 같은, 저전력 고성능 임베디드 시스템은 제한된 리소스를 가지므로, 복잡한 입력 데이터를 처리하는데 필요한 연산량을 감소시키면서도 정확도 손실을 최소화할 수 있는 기술이 요구된다.Neural network devices require a large amount of computation on complex input data. In order for a neural network device to analyze an input in real time and extract information, a technology capable of efficiently processing a neural network operation is required. In particular, since a low-power, high-performance embedded system, such as a smartphone, has limited resources, a technology capable of minimizing loss of accuracy while reducing the amount of computation required to process complex input data is required.

뉴럴 네트워크에서 파라미터를 양자화하는 방법 및 장치를 제공하는데 있다. 또한, 상기 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 컴퓨터로 읽을 수 있는 기록매체를 제공하는 데 있다.It is to provide a method and apparatus for quantizing parameters in a neural network. Further, it is to provide a computer-readable recording medium in which a program for executing the method on a computer is recorded.

해결하고자 하는 기술적 과제는 상기된 바와 같은 기술적 과제들로 한정되지 않으며, 또 다른 기술적 과제들이 유추될 수 있다.The technical problem to be solved is not limited to the technical problems as described above, and other technical problems can be inferred.

일 측면에 따르면, 뉴럴 네트워크에서 파라미터를 양자화하는 방법은, 뉴럴 네트워크의 레이어에서 처리되는 입력 액티베이션 값들 및 웨이트 값들 중 적어도 하나를 포함하는 상기 파라미터에 대한 로그 양자화(log quantization)를 수행함으로써 제 1 양자화 값을 결정하는 단계; 상기 제 1 양자화 값에 대한 역양자화(dequantization)에 의해 획득된 제 1 역양자화 값 상기 파라미터 간의 오차와 임계값을 비교하는 단계; 상기 비교 결과 상기 오차가 상기 임계값보다 큰 경우, 상기 오차에 대한 로그 양자화를 수행함으로써 제 2 양자화 값을 결정하는 단계; 및 상기 파라미터를 상기 제 1 양자화 값 및 상기 제 2 양자화 값이 그룹핑된 값으로 양자화하는 단계를 포함한다. According to an aspect, a method of quantizing a parameter in a neural network includes first quantization by performing log quantization on the parameter including at least one of input activation values and weight values processed in a layer of the neural network. Determining a value; Comparing an error between the parameters and a threshold value of a first inverse quantization value obtained by dequantization of the first quantization value; Determining a second quantization value by performing log quantization on the error when the error is greater than the threshold value as a result of the comparison; And quantizing the parameter into a grouped value of the first quantization value and the second quantization value.

또한, 상기 제 1 양자화 값을 결정하는 단계는, 상기 복수의 양자화 레벨들 중에서 상기 파라미터에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 상기 제 1 양자화 값을 결정하고, 상기 제 2 양자화 값을 결정하는 단계는, 상기 복수의 양자화 레벨들 중에서 상기 오차에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 상기 제 2 양자화 값을 결정한다.In addition, the determining of the first quantization value may include determining the first quantization value by performing log quantization on a value corresponding to a quantization level closest to the parameter among the plurality of quantization levels, and In determining the 2 quantization value, the second quantization value is determined by performing log quantization on a value corresponding to the quantization level closest to the error among the plurality of quantization levels.

또한, 상기 제 2 양자화 값은, 상기 제 1 양자화 값을 나타내는 비트 수와 동일한 비트 수로 표현될 수 있다.Also, the second quantization value may be expressed by the same number of bits as the number of bits representing the first quantization value.

또한, 상기 임계값은, 상기 뉴럴 네트워크의 인식률 및 상기 파라미터의 양자화에 따른 데이터의 크기 간의 트레이드-오프(trade off) 관계에 기초하여 결정될 수 있다.Also, the threshold value may be determined based on a trade-off relationship between a recognition rate of the neural network and a size of data according to quantization of the parameter.

또한, 상기 양자화하는 단계는, 상기 제 1 양자화 값 및 상기 제 2 양자화 값 각각에 태그 비트(tag bit)를 추가하는 단계를 더 포함할 수 있다. In addition, the quantizing step may further include adding a tag bit to each of the first quantization value and the second quantization value.

또한, 상기 추가하는 단계는, 상기 제 1 양자화 값에 연속된 상기 제 2 양자화 값이 있음을 나타내는 제 1 태그 비트를 상기 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가하고, 상기 제 2 양자화 값에 연속된 양자화 값이 없음을 나타내는 제 2 태그 비트를 상기 제 2 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가할 수 있다.In addition, the step of adding may include a first tag bit indicating that the second quantization value is present in the first quantization value before or after the first bit of the bits indicating the first quantization value. In addition, a second tag bit indicating that there is no consecutive quantization value in the second quantization value may be added before the first bit or after the last bit among the bits indicating the second quantization value.

또한, 상기 양자화하는 단계는, 상기 제 1 양자화 값을 구성하는 비트들 중 첫 번째 비트의 앞 및 상기 제 2 양자화 값을 나타내는 비트들 중 마지막 비트의 뒤 중 어느 하나에, 상기 제 1 양자화 값 및 상기 제 2 양자화 값이 연속된 값임을 나타내는 코드 값을 추가하는 단계를 더 포함할 수 있다. In addition, in the quantizing step, the first quantization value and the second quantization value, in any one of the front of the first bit of the bits constituting the first quantization value and the rear of the last bit of the bits representing the second quantization value, and It may further include the step of adding a code value indicating that the second quantization value is a continuous value.

또한, 뉴럴 네트워크의 레이어에서 처리되는 입력 액티베이션 값들 및 웨이트 값들 중 적어도 하나를 포함하는 파라미터를 양자화하는 방법은, 상기 그룹핑된 값을 역양자화하는 단계; 및 상기 그룹핑된 값을 역양자화한 값과 상기 입력 액티베이션 값들간의 컨볼루션(convolution) 연산을 수행하는 단계를 더 포함할 수 있다.In addition, a method of quantizing a parameter including at least one of input activation values and weight values processed in a layer of a neural network may include inverse quantizing the grouped values; And performing a convolution operation between a value obtained by inverse quantization of the grouped value and the input activation values.

또한, 상기 그룹핑된 값을 역 양자화하는 단계는, 상기 제 1 양자화 값을 역양자화한 값인 제 1 역양자화 값 및 상기 제 2 양자화 값을 역양자화한 값인 제 2 역양자화 값 각각을 산출하는 단계; 및상기 제 1 역양자화 값 및 상기 제 2 역양자화 값을 더하여 상기 그룹핑된 값을 역양자화 값을 획득하는 단계를 더 포함할 수 있다.The inverse quantization of the grouped values may include calculating a first inverse quantization value that is a value obtained by inverse quantization of the first quantization value and a second inverse quantization value that is a value obtained by inverse quantization of the second quantization value; And obtaining an inverse quantization value from the grouped value by adding the first inverse quantization value and the second inverse quantization value.

다른 측면에 따르면, 뉴럴 네트워크를 실시(implement)하는 장치에 있어서, 메모리; 및 뉴럴 네트워크의 레이어에서 처리되는 입력 액티베이션 값들 및 웨이트 값들 중 적어도 하나를 포함하는 파라미터를 양자화하는 프로세서를 포함하고, 상기 프로세서는, 파라미터에 대한 로그 양자화(log quantization)를 수행함으로써 제 1 양자화 값을 결정하고, 상기 제 1 양자화 값에 대한 역양자화(dequantization)에 의해 획득된 제 1 역양자화 값 및 상기 파라미터 간의 오차와 임계값을 비교하고, 상기 오차가 상기 임계값보다 큰 경우, 상기 오차에 대한 로그 양자화를 수행함으로써 제 2 양자화 값을 결정하고, 상기 파라미터를 상기 제 1 양자화 값 및 상기 제 2 양자화 값이 그룹핑된 값으로 양자화한다.According to another aspect, an apparatus for implementing a neural network, comprising: a memory; And a processor that quantizes a parameter including at least one of input activation values and weight values processed in a layer of the neural network, wherein the processor performs log quantization on the parameter to determine the first quantization value. Determine and compare an error and a threshold value between a first inverse quantization value obtained by dequantization of the first quantization value and the parameter, and if the error is greater than the threshold value, A second quantization value is determined by performing logarithmic quantization, and the parameter is quantized into a value obtained by grouping the first quantization value and the second quantization value.

또한, 상기 프로세서는, 상기 복수의 양자화 레벨들 중에서 상기 파라미터에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 상기 제 1 양자화 값을 결정하고, 상기 복수의 양자화 레벨들 중에서 상기 오차에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 상기 제 2 양자화 값을 결정할 수 있다.In addition, the processor determines the first quantization value by performing log quantization on a value corresponding to a quantization level closest to the parameter among the plurality of quantization levels, and the error among the plurality of quantization levels The second quantization value may be determined by performing log quantization on the value corresponding to the quantization level closest to.

또한, 상기 제 2 양자화 값은, 상기 제 1 양자화 값을 나타내는 비트 수와 동일한 비트 수로 표현될 수 있다.Also, the second quantization value may be expressed by the same number of bits as the number of bits representing the first quantization value.

또한, 상기 임계값은, 상기 뉴럴 네트워크의 인식률 및 상기 파라미터의 양자화에 따른 데이터의 크기 간의 트레이드-오프(trade off) 관계에 기초하여 결정될 수 있다.Also, the threshold value may be determined based on a trade-off relationship between a recognition rate of the neural network and a size of data according to quantization of the parameter.

또한, 상기 프로세서는, 상기 제 1 양자화 값 및 상기 제 2 양자화 값 각각에 태그 비트(tag bit)를 추가할 수 있다.In addition, the processor may add a tag bit to each of the first quantization value and the second quantization value.

또한, 상기 프로세서는, 상기 제 1 양자화 값에 연속된 상기 제 2 양자화 값이 있음을 나타내는 제 1 태그 비트를 상기 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가하고, 상기 제 2 양자화 값에 연속된 양자화 값이 없음을 나타내는 제 2 태그 비트를 상기 제 2 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가할 수 있다. In addition, the processor adds a first tag bit indicating that the second quantization value is contiguous to the first quantization value, before or after the first bit of the bits indicating the first quantization value, and , A second tag bit indicating that there is no consecutive quantization value in the second quantization value may be added before the first bit or after the last bit among bits indicating the second quantization value.

또한, 상기 프로세서는, 상기 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 및 상기 제 2 양자화 값을 구성하는 비트들 중 마지막 비트의 뒤 중 어느 하나에, 상기 제 1 양자화 값 및 상기 제 2 양자화 값이 연속된 값임을 나타내는 코드 값을 추가할 수 있다.In addition, the processor may include the first quantization value and the first quantization value in any one of bits before a first bit among bits representing the first quantization value and after a last bit among bits constituting the second quantization value. 2 A code value indicating that the quantization value is a continuous value can be added.

또한, 상기 프로세서는, 상기 그룹핑된 값을 역양자화하고, 상기 그룹핑된 값을 역양자화한 값과 상기 입력 액티베이션 값들간의 컨볼루션(convolution) 연산을 수행할 수 있다. In addition, the processor may inverse quantize the grouped values and perform a convolution operation between a value obtained by inverse quantization of the grouped values and the input activation values.

또한, 상기 프로세서는, 상기 제 1 양자화 값을 역양자화한 값인 제 1 역양자화 값 및 상기 제 2 양자화 값을 역양자화한 값인 제 2 역양자화 값 각각을 산출하고, 상기 제 1 역양자화 값 및 상기 제 2 역양자화 값을 더하여 상기 그룹핑된 값을 역양자화 값을 획득할 수 있다. In addition, the processor calculates each of a first inverse quantization value that is a value obtained by inverse quantization of the first quantization value and a second inverse quantization value that is a value obtained by inverse quantization of the second quantization value, and the first inverse quantization value and the An inverse quantization value may be obtained from the grouped value by adding a second inverse quantization value.

또 다른 측면에 따르면, 컴퓨터로 읽을 수 있는 기록매체는 상술한 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 컴퓨터로 읽을 수 있는 기록매체를 포함할 수 있다.According to another aspect, the computer-readable recording medium may include a computer-readable recording medium recording a program for executing the above-described method on a computer.

도 1은 뉴럴 네크워크 아키텍처의 일 예를 설명하기 위한 도면이다.
도 2는 뉴럴 네트워크에서 수행되는 연산의 일 예를 설명하기 위한 도면이다.
도 3은 선형 양자화(linear quantization) 방식 및 로그 양자화(log quantization) 방식의 일 예를 나타내는 도면이다.
도 4는 선형 양자화 방식 및 로그 양자화 방식 각각에 대하여 양자화 에러의 일 예를 나타내는 도면이다.
도 5는 뉴럴 네트워크에서 파라미터를 양자화하는 방법의 일 예를 나타내는 흐름도이다.
도 6은 뉴럴 네트워크 장치가 제 1 양자화 값을 결정하는 일 예를 나타낸다.
도 7은 뉴럴 네트워크 장치가 제 1 역양자화 값과 파라미터의 차이가 임계값보다 큰 지 판단하는 일 예를 나타낸다.
도 8은 뉴럴 네트워크 장치가 제 2 양자화 값을 결정하는 일 예를 나타내는 도면이다.
도 9는 태그 비트(tag bit)를 이용하여 제 1 양자화 값 및 제 2 양자화 값이 하나의 파라미터를 양자화한 값임을 나타내는 일 예를 나타내는 도면이다.
도 10은 코드 값을 이용하여 제 1 양자화 값 및 제 2 양자화 값이 하나의 파라미터를 양자화한 값임을 나타내는 일 예를 나타내는 도면이다.
도 11은 뉴럴 네트워크 장치가 파라미터를 양자화하는 방법의 일 예를 설명하기 위한 흐름도이다.
도 12는 뉴럴 네트워크 장치가 파라미터를 역양자화하는 방법의 일 예를 설명하기 위한 흐름도이다.
도 13은 뉴럴 네트워크에서 파라미터를 양자화하는 방식에 따른 정확도를 비교한 도면이다.
도 14는 MAC(Multiplication and Accumulation) 연산을 수행하는 연산 장치의 일 예를 나타내는 도면이다.
도 15는 MAC(Multiplication and Accumulation) 연산을 수행하는 연산 장치의 다른 예를 나타내는 도면이다.
도 16은 일 실시예에 따른 전자 시스템을 나타내는 블록도이다.
도 17은 뉴럴 네트워크 장치의 구성의 일 예를 도시한 블록도이다.
1 is a diagram for describing an example of a neural network architecture.
2 is a diagram for describing an example of an operation performed in a neural network.
3 is a diagram showing an example of a linear quantization method and a log quantization method.
4 is a diagram showing an example of a quantization error for each of a linear quantization method and a log quantization method.
5 is a flowchart illustrating an example of a method of quantizing parameters in a neural network.
6 shows an example in which a neural network device determines a first quantization value.
7 shows an example in which a neural network device determines whether a difference between a first inverse quantization value and a parameter is greater than a threshold value.
8 is a diagram illustrating an example in which a neural network device determines a second quantization value.
FIG. 9 is a diagram illustrating an example in which a first quantization value and a second quantization value are quantized values of one parameter using a tag bit.
10 is a diagram illustrating an example in which a first quantization value and a second quantization value are quantized values of one parameter using a code value.
11 is a flowchart illustrating an example of a method for quantizing a parameter by a neural network device.
12 is a flowchart illustrating an example of a method of inverse quantizing a parameter by a neural network device.
13 is a diagram comparing accuracy according to a method of quantizing parameters in a neural network.
14 is a diagram illustrating an example of a computing device that performs a multiplication and accumulation (MAC) operation.
15 is a diagram illustrating another example of a computing device that performs a multiplication and accumulation (MAC) operation.
16 is a block diagram illustrating an electronic system according to an exemplary embodiment.
17 is a block diagram illustrating an example of a configuration of a neural network device.

실시예들에서 사용되는 용어는 가능한 현재 널리 사용되는 일반적인 용어들을 선택하였으나, 이는 당 기술분야에 종사하는 기술자의 의도 또는 판례, 새로운 기술의 출현 등에 따라 달라질 수 있다. 또한, 특정한 경우는 임의로 선정된 용어도 있으며, 이 경우 해당 실시예의 설명 부분에서 상세히 그 의미를 기재할 것이다. 따라서, 명세서에서 사용되는 용어는 단순한 용어의 명칭이 아닌, 그 용어가 가지는 의미와 본 실시예들의 전반에 걸친 내용을 토대로 정의되어야 한다.As for the terms used in the embodiments, general terms that are currently widely used as possible are selected, but this may vary according to the intention or precedent of a technician working in the art, and the emergence of new technologies. In addition, in certain cases, there are terms that are arbitrarily selected, and in this case, the meaning will be described in detail in the description of the corresponding embodiment. Accordingly, terms used in the specification should be defined based on the meaning of the term and the overall contents of the present embodiments, not a simple name of the term.

명세서 전체에서, 어떤 부분이 다른 부분과 연결되어 있다고 할 때, 이는 직접적으로 연결되어 있는 경우뿐 아니라, 그 중간에 다른 구성요소를 사이에 두고 전기적으로 연결되어 있는 경우도 포함한다. 또한 어떤 부분이 어떤 구성요소를 포함한다고 할 때, 이는 특별히 반대되는 기재가 없는 한 다른 구성요소를 제외하는 것이 아니라 다른 구성요소를 더 포함할 수 있는 것을 의미한다.Throughout the specification, when a part is said to be connected to another part, this includes not only a case in which it is directly connected, but also a case in which it is electrically connected with another component interposed therebetween. In addition, when a certain part includes a certain component, it means that other components may be further included, rather than excluding other components unless specifically stated to the contrary.

명세서에 기재된 "구성된다" 또는 "포함한다" 등의 용어는 명세서 상에 기재된 여러 구성 요소들, 또는 여러 단계들을 반드시 모두 포함하는 것으로 해석되지 않아야 하며, 그 중 일부 구성 요소들 또는 일부 단계들은 포함되지 않을 수도 있고, 또는 추가적인 구성 요소 또는 단계들을 더 포함할 수 있는 것으로 해석되어야 한다.Terms such as “consisting of” or “comprising” described in the specification should not be construed as necessarily including all of the various elements or various steps described in the specification, and some of the elements or some steps are included It should be construed that it may not be, or may further include additional components or steps.

이하 첨부된 도면들을 참조하면서 실시예들을 상세히 설명하기로 한다. 그러나 실시 예는 여러 가지 상이한 형태로 구현될 수 있으며 이하에서 설명하는 예에 한정되지 않는다.Hereinafter, exemplary embodiments will be described in detail with reference to the accompanying drawings. However, the embodiments may be implemented in various different forms and are not limited to the examples described below.

도 1은 뉴럴 네크워크 아키텍처의 일 예를 설명하기 위한 도면이다.1 is a diagram for describing an example of a neural network architecture.

도 1에 도시된 뉴럴 네트워크(1)는 딥 뉴럴 네트워크(Deep Neural Network, 이하 'DNN'이라고 함) 아키텍처의 일 예일 수 있다. DNN은 컨볼루션 뉴럴 네트워크(Convolutional Neural Networks, CNN), 리커런트 뉴럴 네트워크(Recurrent Neural Networks, RNN), Deep Belief Networks, Restricted Boltzman Machines 등에 해당할 수 있으나 이에 한정되지 않는다. 뉴럴 네트워크(1)는 입력 레이어(Layer 1), 4개의 히든 레이어들(Layer 2, Layer 3, Layer 4, Layer 5) 및 출력 레이어(Layer 6)를 포함하는 DNN일 수 있다. 예를 들어, 뉴럴 네트워크(1)가 컨볼루션 뉴럴 네트워크(CNN)를 표현하는 것인 경우, Layer 1 내지 Layer 6는 컨볼루션 뉴럴 네트워크 중 일부의 레이어들에 해당될 수 있으며, 이는 컨볼루션 레이어, 풀링 레이어(pooling layer), 풀리 커넥티드(fully connected) 레이어 등에 해당될 수 있다.The neural network 1 illustrated in FIG. 1 may be an example of a deep neural network (hereinafter referred to as “DNN”) architecture. DNN may correspond to Convolutional Neural Networks (CNN), Recurrent Neural Networks (RNN), Deep Belief Networks, Restricted Boltzman Machines, etc., but is not limited thereto. The neural network 1 may be a DNN including an input layer (Layer 1), four hidden layers (Layer 2, Layer 3, Layer 4, and Layer 5), and an output layer (Layer 6). For example, when the neural network 1 represents a convolutional neural network (CNN), Layers 1 to 6 may correspond to some layers of the convolutional neural network, which is a convolutional layer, It may correspond to a pooling layer, a fully connected layer, and the like.

뉴럴 네트워크(1)에 포함된 레이어들 각각은 "뉴런(neuron)", "프로세싱 엘리먼트(Processing element: PE)", "유닛(unit)" 또는 이와 유사한 용어들로 알려진, 복수의 인공 노드(artificial node)들을 포함할 수 있다. 예를 들어, 도 1에 도시된 바와 같이, Layer 1은 5개의 노드들, Layer 2는 7개의 노드들을 포함할 수 있다. 다만, 이는 예시에 불과할 뿐 뉴럴 네트워크(1)에 포함된 레이어들 각각은 다양한 개수의 노드들을 포함할 수 있다.Each of the layers included in the neural network 1 is a plurality of artificial nodes, known as "neurons", "processing elements (PE)", "units" or similar terms. node). For example, as shown in FIG. 1, Layer 1 may include 5 nodes, and Layer 2 may include 7 nodes. However, this is only an example, and each of the layers included in the neural network 1 may include various numbers of nodes.

뉴럴 네트워크(1)에 포함된 레이어들 각각에 포함된 노드들은 서로 연결되어 데이터를 교환할 수 있다. 예를 들어, 하나의 노드는 다른 노드들로부터 데이터를 수신하여 연산할 수 있고, 연산 결과를 또 다른 노드들로 출력할 수 있다.Nodes included in each of the layers included in the neural network 1 may be connected to each other to exchange data. For example, one node may receive data from other nodes and perform an operation, and output the operation result to other nodes.

한편, 뉴럴 네트워크(1)가 DNN 아키텍처로 구현된 경우 유효한 정보를 처리할 수 있는 많은 레이어들을 포함할 수 있다. 따라서, 뉴럴 네트워크(1)는 싱글 레이어를 포함하는 뉴럴 네트워크보다 복잡한 데이터 집합들을 처리할 수 있다. 한편, 도 1에는 뉴럴 네트워크(1)가 6개의 레이어들을 포함하는 것으로 도시되어 있으나, 이는 예시에 불과할 뿐 뉴럴 네트워크(1)는 더 적거나 많은 레이어들을 포함할 수 있다. 즉, 뉴럴 네트워크(1)는 도 1에 도시된 것과는 다른, 다양한 구조의 레이어들을 포함할 수 있다. Meanwhile, when the neural network 1 is implemented with a DNN architecture, it may include many layers capable of processing valid information. Therefore, the neural network 1 can process more complex data sets than a neural network including a single layer. Meanwhile, although FIG. 1 shows that the neural network 1 includes 6 layers, this is only an example, and the neural network 1 may include fewer or more layers. That is, the neural network 1 may include layers of various structures different from those shown in FIG. 1.

도 2는 뉴럴 네트워크에서 수행되는 연산의 일 예를 설명하기 위한 도면이다.2 is a diagram for describing an example of an operation performed in a neural network.

도 2를 참조하면, 뉴럴 네트워크(2)는 입력 레이어, 히든 레이어들 및 출력 레이어를 포함하는 구조를 가지며, 수신되는 입력 데이터(예를 들어,

Figure pat00001
Figure pat00002
)를 기초로 연산을 수행하고, 수행 결과를 기초로 출력 데이터(예를 들어,
Figure pat00003
Figure pat00004
)를 생성할 수 있다.2, the neural network 2 has a structure including an input layer, hidden layers, and an output layer, and received input data (for example,
Figure pat00001
And
Figure pat00002
) To perform an operation, and output data (for example,
Figure pat00003
And
Figure pat00004
) Can be created.

뉴럴 네트워크(2)는 앞서 설명된 바와 같이, 2개 이상의 히든 레이어들을 포함하는 DNN 또는 n-계층 뉴럴 네트워크일 수 있다. 예를 들어, 도 2에 도시된 바와 같이, 뉴럴 네트워크(2)는 입력 레이어(Layer 1), 2개의 히든 레이어들(Layer 2 및 Layer 3) 및 출력 레이어(Layer 4)를 포함하는 DNN일 수 있다. 뉴럴 네트워크(2)가 DNN 아키텍처로 구현된 경우 유효한 정보를 처리할 수 있는 보다 많은 레이어들을 포함하므로, 뉴럴 네트워크(2)는 싱글 레이어를 갖는 뉴럴 네트워크보다 복잡한 데이터 집합들을 처리할 수 있다. 한편, 뉴럴 네트워크(2)는 4개의 레이어들을 포함하는 것으로 도시되어 있으나, 이는 예시에 불과할 뿐 뉴럴 네트워크(2)는 더 적거나 많은 레이어들을 포함하거나, 더 적거나 많은 채널들을 포함할 수 있다. 즉, 뉴럴 네트워크(2)는 도 2에 도시된 것과는 다른, 다양한 구조의 레이어들을 포함할 수 있다.As described above, the neural network 2 may be a DNN or an n-layer neural network including two or more hidden layers. For example, as shown in FIG. 2, the neural network 2 may be a DNN including an input layer (Layer 1), two hidden layers (Layer 2 and Layer 3), and an output layer (Layer 4). have. When the neural network 2 is implemented with a DNN architecture, since it includes more layers capable of processing valid information, the neural network 2 can process more complex data sets than a neural network having a single layer. Meanwhile, the neural network 2 is shown to include four layers, but this is only an example, and the neural network 2 may include fewer or more layers, or fewer or more channels. That is, the neural network 2 may include layers of various structures different from those shown in FIG. 2.

뉴럴 네트워크(2)에 포함된 레이어들 각각은 복수의 채널들을 포함할 수 있다. 채널은 뉴런(neuron), 프로세싱 엘리먼트(Processing element, PE), 유닛(unit) 또는 이와 유사한 용어들로 알려진, 복수의 인공 노드(artificial node)들에 해당될 수 있다. 예를 들어, 도 2에 도시된 바와 같이, Layer 1은 2개의 채널들(노드들), Layer 2 및 Layer 3 각각은 3개의 채널들을 포함할 수 있다. 다만, 이는 예시에 불과할 뿐 뉴럴 네트워크(2)에 포함된 레이어들 각각은 다양한 개수의 채널들(노드들)을 포함할 수 있다.Each of the layers included in the neural network 2 may include a plurality of channels. A channel may correspond to a plurality of artificial nodes, known as neurons, processing elements (PEs), units, or similar terms. For example, as shown in FIG. 2, Layer 1 may include two channels (nodes), and each of Layer 2 and Layer 3 may include three channels. However, this is only an example, and each of the layers included in the neural network 2 may include a variety of channels (nodes).

뉴럴 네트워크(2)의 레이어들 각각에 포함된 채널들은 서로 연결되어 데이터를 처리할 수 있다. 예를 들어, 하나의 채널은 다른 채널들로부터 데이터를 수신하여 연산할 수 있고, 연산 결과를 또 다른 채널들로 출력할 수 있다.Channels included in each of the layers of the neural network 2 are connected to each other to process data. For example, one channel may receive data from other channels and perform an operation, and the operation result may be output to other channels.

채널들 각각의 입력 및 출력 각각은 입력 액티베이션 및 출력 액티베이션이라고 지칭될 수 있다. 즉, 액티베이션은 한 채널의 출력임과 동시에, 다음 레이어에 포함된 채널들의 입력에 해당되는 파라미터일 수 있다. 한편, 채널들 각각은 이전 레이어에 포함된 채널들로부터 수신된 액티베이션들 및 웨이트 및 바이어스에 기초하여 자신의 액티베이션을 결정할 수 있다. 웨이트는 각 채널에서의 출력 액티베이션을 계산하기 위해 이용되는 파라미터로서, 채널들 간의 연결관계에 할당되는 값일 수 있다.Each of the input and output of each of the channels may be referred to as input activation and output activation. That is, activation may be an output of one channel and a parameter corresponding to an input of channels included in the next layer. Meanwhile, each of the channels may determine its own activation based on activations, weight and bias received from channels included in the previous layer. The weight is a parameter used to calculate the output activation in each channel, and may be a value assigned to a connection relationship between channels.

채널들 각각은 입력을 수신하여 출력 액티베이션을 출력하는 연산 유닛(computational unit) 또는 프로세싱 엘리먼트(processing element)에 의해 처리될 수 있고, 채널들 각각의 입력-출력은 매핑될 수 있다. 예를 들어,

Figure pat00005
는 액티베이션 함수(activation function)이고,
Figure pat00006
는 (i-1) 번째 레이어에 포함된 k 번째 채널로부터 i 번째 레이어에 포함된 j번째 채널로의 웨이트며,
Figure pat00007
는 i 번째 레이어에 포함된 j 번째 채널의 바이어스(bias)이고,
Figure pat00008
는 i 번째 레이어의 j 번째 채널의 액티베이션이라고 할 때, 액티베이션
Figure pat00009
는 다음과 같은 수학식 1을 이용하여 계산될 수 있다.Each of the channels may be processed by a computational unit or a processing element that receives an input and outputs an output activation, and the input-output of each of the channels may be mapped. For example,
Figure pat00005
Is the activation function,
Figure pat00006
Is the weight from the k-th channel included in the (i-1)-th layer to the j-th channel included in the i-th layer,
Figure pat00007
Is the bias of the j-th channel included in the i-th layer,
Figure pat00008
Is the activation of the j-th channel of the i-th layer,
Figure pat00009
Can be calculated using Equation 1 as follows.

Figure pat00010
Figure pat00010

도 2에 도시된 바와 같이, 2번째 레이어(Layer 2)의 첫 번째 채널(CH 1)의 액티베이션은

Figure pat00011
로 표현될 수 있다. 또한,
Figure pat00012
은 수학식 1에 따라
Figure pat00013
의 값을 가질 수 있다. 다만, 앞서 설명한 수학식 1은 뉴럴 네트워크(2)에서 데이터를 처리하기 위해 이용되는 액티베이션 및 웨이트 및 바이어스를 설명하기 위한 예시일 뿐, 이에 제한되지 않는다. 액티베이션은 이전 레이어로부터 수신된 액티베이션들의 가중치 합(weighted sum)을 sigmoid 함수나 Rectified Linear Unit (ReLU) 함수 등의 액티베이션 함수에 통과시킴으로써 획득된 값일 수 있다.As shown in FIG. 2, activation of the first channel (CH 1) of the second layer (Layer 2) is
Figure pat00011
It can be expressed as Also,
Figure pat00012
Is according to Equation 1
Figure pat00013
It can have a value of However, Equation 1 described above is only an example for explaining activation, weight, and bias used to process data in the neural network 2, and is not limited thereto. The activation may be a value obtained by passing a weighted sum of activations received from a previous layer through an activation function such as a sigmoid function or a Rectified Linear Unit (ReLU) function.

일반적으로 레이어들의 입력으로 부동 소수점 포맷 및 고정 소수점 포맷의 파라미터들이 이용될 수 있다. 또한 웨이트와 바이어스 값으로 부동 소수점 포맷 및 고정 소수점 포맷의 파라미터들이 이용될 수 있다. In general, parameters of a floating-point format and a fixed-point format may be used as inputs to the layers. In addition, parameters of a floating-point format and a fixed-point format may be used as weight and bias values.

앞서 설명한 것과 같이, 뉴럴 네트워크(2)에서는 수많은 데이터 집합들이 상호 연결된 복수의 채널들 간에 교환되고, 레이어를 지나면서 수많은 연산 과정을 거친다. 따라서, 복잡한 입력 데이터를 처리하는데 필요한 연산량을 감소시키면서도 정확도 손실을 최소화할 수 있는 기술이 요구된다.As described above, in the neural network 2, numerous data sets are exchanged between a plurality of interconnected channels, and a number of calculation processes are performed while passing through layers. Accordingly, there is a need for a technique capable of minimizing loss of accuracy while reducing the amount of computation required to process complex input data.

도 3은 선형 양자화(linear quantization) 방식 및 로그 양자화(log quantization) 방식의 일 예를 나타내는 도면이다. 3 is a diagram showing an example of a linear quantization method and a log quantization method.

뉴럴 네트워크에서 발생되는 많은 연산량을 줄이기 위해 뉴럴 네트워크가 포함하는 파라미터들의 다양한 양자화 방식에 대한 연구가 진행되었다. 예를 들어, 웨이트 파라미터들을 원래의 비트 길이 보다 작은 길이의 비트들로 양자화함으로써, 정확도가 다소 감소되더라도 웨이트 파라미터들의 처리에 필요한 연산량을 줄일 수 있다. 이러한 양자화 방식으로는 선형 양자화(linear quantization) 방식 및 로그 양자화(log quantization) 방식 등이 있다.In order to reduce the amount of computation generated in the neural network, studies on various quantization methods of parameters included in the neural network have been conducted. For example, by quantizing the weight parameters into bits having a length smaller than the original bit length, it is possible to reduce the amount of computation required for processing the weight parameters even though the accuracy is slightly reduced. Such quantization methods include a linear quantization method and a log quantization method.

선형 양자화 방식은 양자화의 대상이 되는 뉴럴 네트워크의 파라미터들에 일정한 간격의 양자화 레벨들을 할당하는 양자화 방식이다. 반면, 로그 양자화 방식은 로그 데이터 표현(logarithm data representation)을 기반으로 양자화 레벨들을 할당하므로, 큰 값들 근처의 파라미터들에 상대적으로 적은 양자화 레벨을 할당하고, 0 근처의 파라미터들에 상대적으로 많은 양자화 레벨들을 할당하는 양자화 방식이다. The linear quantization method is a quantization method in which quantization levels at regular intervals are allocated to parameters of a neural network to be quantized. On the other hand, since the logarithm quantization method allocates quantization levels based on logarithm data representation, a relatively small quantization level is allocated to parameters near large values, and relatively large quantization levels are assigned to parameters near zero. It is a quantization method to allocate.

예를 들어, 도 3을 참조하면, -1 내지 1 구간 내에 존재하는 파라미터의 실제값(real value) x는 양자화된 정수값 q로 양자화될 수 있다. q는 -M 부터 M-1 사이의 정수값일 수 있으며, M은 예를 들어 2N-1일 수 있다. For example, referring to FIG. 3, a real value x of a parameter existing in the interval -1 to 1 may be quantized to a quantized integer value q. q may be an integer value between -M and M-1, and M may be 2N-1, for example.

선형 양자화 방식에 의하면, -1 내지 -(1-1/M) 구간 내의 x는 정수값 -M으로 양자화될 수 있고, -(1-1/M) 내지 -(1-2/M) 구간 내의 x는 정수값 -(M-1)으로 양자화될 수 있다. 마찬가지로, 1-1/M 내지 1 구간 내의 x는 정수값 M-1로 양자화될 수 있다. According to the linear quantization method, x in the interval -1 to -(1-1/M) can be quantized to an integer value -M, and in the interval -(1-1/M) to -(1-2/M) x can be quantized to an integer value -(M-1). Likewise, x in the interval 1-1/M to 1 may be quantized to an integer value M-1.

한편, 로그 양자화 방식에 의하면, -2-M 내지 -2-(M-1) 구간 내의 x는 정수값 -M으로 양자화될 수 있고, -2-(M-1) 내지 --2-(M-2) 구간 내의 x는 정수값 -(M-1)으로 양자화될 수 있다. 마찬가지로, 2-(M-1) 내지 2-M 구간 내의 x는 정수값 M-1로 양자화될 수 있다.On the other hand, according to the logarithmic quantization method, x in the interval -2-M to -2-(M-1) can be quantized to an integer value -M, and -2-(M-1) to --2-(M -2) x in the interval can be quantized to an integer value -(M-1). Likewise, x in the interval 2-(M-1) to 2-M may be quantized to an integer value M-1.

도 4는 선형 양자화 방식 및 로그 양자화 방식 각각에 대하여 양자화 오차의 일 예를 나타내는 도면이다. 4 is a diagram illustrating an example of a quantization error for each of a linear quantization method and a log quantization method.

양자화 오차는, 파라미터의 실제값 x 및 양자화된 정수값 q간의 차이를 나타낼 수 있다. 도 4는 파라미터의 실제값 x 에 따른 양자화 오차값을 나타내는 그래프이다. The quantization error may represent a difference between an actual value x of a parameter and a quantized integer value q. 4 is a graph showing a quantization error value according to an actual value x of a parameter.

파라미터의 실제값 x가 0에 근접하는 값인 경우에, 로그 양자화 방식에 의한 양자화 오차값은 선형 양자화 방식에 의한 양자화 오차값보다 작거나 같을 수 있다. 그러나, 파라미터의 실제값 x가 1에 가까워짐에 따라, 로그 양자화 방식에 의한 양자화 오차값은 선형 양자화 방식에 의한 양자화 오차값보다 커질 수 있다. 한편, 양자화 오차값이 커짐에 따라 뉴럴 네트워크의 인식률이 낮아질 수 있다. 따라서 파라미터의 실제값 x가 1에 가까워지는 경우에 양자화 오차값이 커지는 현상을 해결하기 위한 양자화 방식이 요구된다. When the actual value x of the parameter is a value approaching 0, the quantization error value according to the log quantization method may be less than or equal to the quantization error value according to the linear quantization method. However, as the actual value x of the parameter approaches 1, the quantization error value by the log quantization method may be larger than the quantization error value by the linear quantization method. Meanwhile, as the quantization error value increases, the recognition rate of the neural network may decrease. Therefore, a quantization method is required to solve the phenomenon that the quantization error value increases when the actual value x of the parameter approaches 1.

이에 기존의 로그 양자화 방식에서는 파라미터를 하나의 양자화 값으로 표현하는데 반해, 본 실시예는 양자화 오차값이 임계값 이상인 경우에는 두 개 이상의 양자화 값으로 표현하는 로그 양자화 방식을 제안한다. 또한, 본 실시예는 제안하는 양자화 방식을 이용하여 뉴럴 네트워크 내 파라미터들을 양자화하여 저장하고, 이를 다시 역양자화하여 연산을 수행하는 등의 프로세싱 기능들을 갖는 뉴럴 네트워크의 생성을 목적으로 할 수 있다. 이하 도 5 내지 도 17을 참조하여 상세히 설명한다.Accordingly, in the conventional log quantization method, a parameter is expressed as one quantization value, whereas the present embodiment proposes a log quantization method that expresses two or more quantization values when the quantization error value is greater than or equal to a threshold value. In addition, the present embodiment may aim to generate a neural network having processing functions such as quantizing and storing parameters in a neural network using the proposed quantization method, and performing an operation by inverse quantizing the parameters. Hereinafter, it will be described in detail with reference to FIGS. 5 to 17.

도 5는 뉴럴 네트워크에서 파라미터를 양자화하는 방법의 일 예를 나타내는 흐름도이다. 5 is a flowchart illustrating an example of a method of quantizing parameters in a neural network.

도 5를 참조하면, 뉴럴 네트워크에서 파라미터를 양자화하는 방법은 도 17에 도시된 뉴럴 네트워크 장치에서 시계열적으로 처리되는 단계들로 구성된다. 따라서, 이하에서 생략된 내용이라 하더라도 도 17에 도시된 뉴럴 네트워크 장치에 관하여 후술할 내용은 도 5의 방법에도 적용됨을 알 수 있다.Referring to FIG. 5, a method of quantizing a parameter in a neural network includes steps processed in a time series in the neural network device shown in FIG. 17. Accordingly, it can be seen that even though the contents are omitted below, the contents to be described later with respect to the neural network device shown in FIG. 17 are also applied to the method of FIG. 5.

510 단계에서, 뉴럴 네트워크 장치는 파라미터에 대한 로그 양자화(log quantization)를 수행함으로써 제 1 양자화 값을 결정할 수 있다. In step 510, the neural network device may determine the first quantization value by performing log quantization on the parameter.

파라미터는 뉴럴 네트워크의 레이어에서 처리되는 액티베이션 값들 및 레이어에서 처리되는 웨이트 값들 중 적어도 하나를 포함할 수 있으나, 이에 제한되는 것은 아니다. The parameter may include at least one of activation values processed by a layer of a neural network and weight values processed by a layer, but is not limited thereto.

도 6은 뉴럴 네트워크 장치가 제 1 양자화 값을 결정하는 일 예를 나타낸다.6 shows an example in which a neural network device determines a first quantization value.

도 6을 참조하면, 뉴럴 네트워크 장치는 밑이 2인 로그 양자화에 기초하여 제 1 양자화 값을 결정하고 있으나, 이에 제한되는 것은 아니며 밑은 2 이외에 다양한 값에 해당할 수 있다. 뉴럴 네트워크 장치는 복수의 양자화 레벨들 중에서 파라미터에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 제 1 양자화 값을 결정할 수 있다.Referring to FIG. 6, the neural network device determines a first quantization value based on log quantization having a base of 2, but is not limited thereto, and the base may correspond to various values other than 2. The neural network apparatus may determine the first quantization value by performing log quantization on a value corresponding to a quantization level closest to a parameter among a plurality of quantization levels.

예를 들어 파라미터의 실제값이 0.5(=2-1)인 경우에, 뉴럴 네트워크 장치는 2의 지수에 해당하는 -1의 절대값에 해당하는 1을 이진법으로 표현하고 이를 제 1 양자화 값으로 결정할 수 있다. 뉴럴 네트워크 장치는 제 1 양자화 값을 5 비트(bit)로 나타낼 수 있으며, 제 1 양자화 값은 00001이 된다. 다만, 이에 제한되는 것은 아니며 제 1 양자화 값은 다양한 비트 수로 표현될 수 있다.For example, if the actual value of the parameter is 0.5 (=2-1), the neural network device expresses 1 corresponding to the absolute value of -1 corresponding to the exponent of 2 in binary and determines this as the first quantization value. I can. The neural network device may represent the first quantization value as 5 bits, and the first quantization value is 00001. However, the present invention is not limited thereto, and the first quantization value may be expressed by various number of bits.

또는 파라미터의 실제값이 -0.25(=-2-2)인 경우에, 뉴럴 네트워크 장치는 2의 지수에 해당하는 -2의 절대값에 해당하는 2을 이진법으로 표현하고 이를 제 1 양자화 값으로 결정할 수 있다. 이 때, 파라미터의 실제값이 음수이므로 뉴럴 네트워크 장치는 2의 보수법을 이용하여, 제 1 양자화 값을 11110으로 결정할 수 있다.Alternatively, if the actual value of the parameter is -0.25 (=-2-2), the neural network device expresses 2 corresponding to the absolute value of -2 corresponding to the exponent of 2 in binary and determines this as the first quantization value. I can. In this case, since the actual value of the parameter is a negative number, the neural network device may determine the first quantization value to be 11110 using a two's complement method.

또는 파라미터의 실제값이 0.4375인 경우에, 뉴럴 네트워크 장치는 0.4375에 근접한 0.5(=2-1)에 대응되는 00001을 제 1 양자화 값으로 결정할 수 있다. 다만, 이에 제한되는 것은 아니며 뉴럴 네트워크의 파라미터에 할당되는 양자화 레벨들의 간격에 따라, 제 1 양자화 값은 다양하게 결정될 수 있다. 예를 들어, 뉴럴 네트워크의 파라미터에 할당되는 복수의 양자화 레벨들에 0.5(=2-1)에 해당하는 양자화 레벨이 포함되지 않을 수 있다. 이러한 경우, 할당되는 복수의 양자화 레벨들 중 0.4375에 가장 근접하는 양자화 레벨에 대응되는 값인 0.25(=2-2)에 대한 로그 양자화를 수행함으로써 00010을 제 1 양자화 값으로 결정할 수 있다.Alternatively, when the actual value of the parameter is 0.4375, the neural network device may determine 00001 corresponding to 0.5 (=2-1) close to 0.4375 as the first quantization value. However, the present invention is not limited thereto, and the first quantization value may be variously determined according to an interval between quantization levels allocated to a parameter of a neural network. For example, a quantization level corresponding to 0.5 (=2-1) may not be included in a plurality of quantization levels allocated to a parameter of a neural network. In this case, 00010 may be determined as the first quantization value by performing log quantization of 0.25 (=2-2), which is a value corresponding to a quantization level closest to 0.4375 among a plurality of allocated quantization levels.

다시 도 5로 돌아오면, 520 단계에서, 뉴럴 네트워크 장치는 제 1 양자화 값에 대한 역양자화(dequantization)에 의해 획득된 제 1 역양자화 값 및 파라미터 간의 오차와 임계값을 비교할 수 있다.Returning to FIG. 5 again, in step 520, the neural network apparatus may compare the first inverse quantization value obtained by dequantization of the first quantization value and the error and the threshold value between the parameters.

뉴럴 네트워크 장치는 제 1 양자화 값을 하기 수학식 2에 의해 역양자화(dequantization, inverse quantization)하여 제 1 역양자화 값을 획득할 수 있다. The neural network device may obtain a first inverse quantization value by performing dequantization (inverse quantization) on the first quantization value according to Equation 2 below.

Figure pat00014
Figure pat00014

상기 수학식 2에서 q는 제 1 양자화 값에 해당할 수 있고,

Figure pat00015
는 제 1 양자화 값을 역양자화한 제 1 역양자화 값에 해당할 수 있다. In Equation 2, q may correspond to a first quantization value,
Figure pat00015
May correspond to a first inverse quantization value obtained by inverse quantization of the first quantization value.

제 1 역양자화 값과 파라미터 간의 오차가 임계값보다 작은 경우에는, 파라미터를 제 1 양자화 값으로 양자화할 수 있다. 그러나, 오차가 임계값보다 큰 경우에는 뉴럴 네트워크의 인식률이 저하되는 문제가 발생할 수 있으므로, 파라미터를 제 1 양자화 값을 포함하는 두 개 이상의 양자화 값으로 표현할 수 있다.When the error between the first inverse quantization value and the parameter is smaller than the threshold value, the parameter may be quantized to the first quantization value. However, when the error is greater than the threshold value, a problem may occur that the recognition rate of the neural network is deteriorated, and thus the parameter may be expressed as two or more quantization values including the first quantization value.

도 7은 뉴럴 네트워크 장치가 제 1 역양자화 값과 파라미터의 차이가 임계값보다 큰 지 판단하는 일 예를 나타낸다. 7 shows an example in which a neural network device determines whether a difference between a first inverse quantization value and a parameter is greater than a threshold value.

도 6에서 상술한 바와 같이, 파라미터의 실제값이 0.5(=2-1)인 경우에 제 1 양자화 값은 00001이 된다. 수학식 1에 기초하여, 제 1 양자화 값인 00001을 역양자화하여 제 1 역양자화 값 0.5를 획득할 수 있다. 파라미터의 실제값인 0.5와 제 1 역양자화 값인 0.5의 차이는 0이다. 따라서, 파라미터의 실제값과 제 1 역양자화 값의 차이가 임계값인 1/128 보다 작으므로, 파라미터는 최종적으로 00001로 양자화될 수 있다.As described above in FIG. 6, when the actual value of the parameter is 0.5 (=2-1), the first quantization value is 00001. Based on Equation 1, a first inverse quantization value of 0.5 may be obtained by inverse quantization of 00001, which is a first quantization value. The difference between 0.5, which is the actual value of the parameter, and 0.5, which is the first inverse quantization value, is 0. Accordingly, since the difference between the actual value of the parameter and the first inverse quantization value is less than 1/128, which is the threshold value, the parameter can be finally quantized to 00001.

마찬가지로, 파라미터의 실제값이 -0.25(=2-2)인 경우에도 파라미터의 실제값과 11110을 역양자화한 제 1 역양자화 값의 차이는 0이므로, 파라미터는 최종적으로 11110으로 양자화될 수 있다.Similarly, even when the actual value of the parameter is -0.25 (=2-2), the difference between the actual value of the parameter and the first inverse quantization value obtained by inverse quantization of 11110 is 0, and thus the parameter can be finally quantized to 11110.

한편, 파라미터의 실제값이 0.4375인 경우에 제 1 양자화 값은 00001이 된다. 00001을 역양자화한 제 1 역양자화 값은 0.5이므로, 파라미터의 실제값인 0.4375와 제 1 역양자화 값인 0.5의 차이는

Figure pat00016
이다. 따라서, 파라미터는 제 1 양자화 값인 00001을 포함하는 두 개 이상의 양자화 값으로 표현될 수 있으며, 이는 도 8에서 후술하도록 한다. Meanwhile, when the actual value of the parameter is 0.4375, the first quantization value is 00001. The first inverse quantization value obtained by inverse quantization of 00001 is 0.5, so the difference between the actual value of the parameter 0.4375 and the first inverse quantization value 0.5 is
Figure pat00016
to be. Accordingly, the parameter may be expressed as two or more quantization values including 00001 as the first quantization value, which will be described later in FIG. 8.

한편, 도 7에서 임계값은 1/128로 설정되어 있으나 이에 제한되는 것은 아니며 임계값은 다양한 값에 해당할 수 있다. 예를 들어, 임계값은 뉴럴 네트워크의 인식률 및 파라미터의 양자화에 따른 데이터의 크기에 기초하여 결정될 수 있다. 임계값이 작을수록 파라미터의 실제값을 높은 정확도로 양자화할 수 있으므로 뉴럴 네트워크의 인식률이 증가하나, 파라미터를 여러 개의 양자화 값으로 표현함에 따라 데이터의 크기가 증가할 수 있다. 따라서, 뉴럴 네트워크의 인식률 및 양자화 값에 해당하는 데이터의 크기 간의 트레이드-오프(trade off) 관계를 고려하여 임계값을 결정할 수 있다. Meanwhile, in FIG. 7, the threshold value is set to 1/128, but is not limited thereto, and the threshold value may correspond to various values. For example, the threshold may be determined based on a recognition rate of a neural network and a size of data according to quantization of a parameter. As the threshold value is smaller, the actual value of the parameter can be quantized with high accuracy, so the recognition rate of the neural network increases, but the size of the data may increase as the parameter is expressed as multiple quantization values. Accordingly, the threshold value may be determined in consideration of a trade-off relationship between the recognition rate of the neural network and the size of data corresponding to the quantization value.

다시 도 5로 돌아오면, 530 단계에서, 뉴럴 네트워크 장치는 비교 결과 오차가 임계값보다 큰 경우, 오차에 대한 로그 양자화를 수행함으로써 제 2 양자화 값을 결정할 수 있다.Referring back to FIG. 5, in step 530, when the comparison result error is greater than the threshold value, the neural network apparatus may determine the second quantization value by performing log quantization on the error.

도 8은 뉴럴 네트워크 장치가 제 2 양자화 값을 결정하는 일 예를 나타내는 도면이다. 8 is a diagram illustrating an example in which a neural network device determines a second quantization value.

뉴럴 네트워크 장치는 제 1 양자화 값을 결정할 때와 마찬가지로, 복수의 양자화 레벨들 중에서 오차에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 제 2 양자화 값을 결정할 수 있다. 이 때, 제 2 양자화 값은 제 1 양자화 값을 나타내는 비트 수와 동일한 비트 수로 표현될 수 있다. 예를 들어 제 1 양자화 값을 5 비트로 나타내는 경우, 뉴럴 네트워크 장치는 제 2 양자화 값 또한 5 비트로 표현할 수 있다. 다만, 이에 제한되는 것은 아니며 제 1 양자화 값과 제 2 양자화 값은 서로 다른 비트 수로 표현될 수도 있다. Similar to when determining the first quantization value, the neural network apparatus may determine the second quantization value by performing log quantization on a value corresponding to a quantization level closest to an error among a plurality of quantization levels. In this case, the second quantization value may be expressed by the same number of bits as the number of bits representing the first quantization value. For example, when the first quantization value is represented by 5 bits, the neural network device may also represent the second quantization value by 5 bits. However, the present invention is not limited thereto, and the first quantization value and the second quantization value may be represented by different number of bits.

도 7에서 상술한 바와 같이, 파라미터의 실제값인 0.4375과 제 1 양자화 값 00001을 역양자화한 제 1 역양자화 값인 0.5간의 오차는 -0.0625이다. 뉴럴 네트워크 장치는 오차에 해당하는 -0.0625(-2-4)에 대해 로그 양자화를 수행할 수 있다. 이 때, 오차 값이 음수이므로 뉴럴 네트워크 장치는 2의 보수법을 이용하여, 제 2 양자화 값을 11110으로 결정할 수 있다.As described above in FIG. 7, an error between 0.4375, which is an actual value of the parameter, and 0.5, which is a first inverse quantization value obtained by inverse quantization of the first quantization value 00001, is -0.0625. The neural network device may perform log quantization on -0.0625 (-2-4) corresponding to the error. In this case, since the error value is a negative number, the neural network apparatus may determine the second quantization value as 11110 using a two's complement method.

다시 도 5로 돌아오면, 540 단계에서, 뉴럴 네트워크 장치는 파라미터를 제 1 양자화 값 및 제 2 양자화 값이 그룹핑된 값으로 양자화할 수 있다.Returning to FIG. 5 again, in step 540, the neural network apparatus may quantize the parameter into a value obtained by grouping the first quantization value and the second quantization value.

예를 들어, 그룹핑된 값은 제 1 양자화 값 다음에 제 2 양자화 값이 연속적으로 위치하여 하나의 그룹을 형성한 값에 해당할 수 있다. 도 8을 참조하면, 파라미터의 실제값인 0.4375인 경우, 뉴럴 네트워크 장치는 파라미터를 제 1 양자화 값에 해당하는 00001 및 제 2 양자화 값에 해당하는 11110이 그룹핑된 값으로 양자화할 수 있다. For example, the grouped value may correspond to a value in which a second quantization value is consecutively positioned after the first quantization value to form one group. Referring to FIG. 8, when the actual value of the parameter is 0.4375, the neural network device may quantize the parameter into a grouped value of 00001 corresponding to a first quantization value and 11110 corresponding to a second quantization value.

한편, 제 1 양자화 값 및 제 2 양자화 값이 하나의 파라미터를 양자화한 값임을 나타내기 위해 추가적으로 코드화 과정이 이루어질 수 있으며 이는 이하 도 9 및 도 10에서 후술하도록 한다. Meanwhile, an additional coding process may be performed to indicate that the first quantization value and the second quantization value are quantized values of one parameter, which will be described later in FIGS. 9 and 10.

도 9는 태그 비트(tag bit)를 이용하여 제 1 양자화 값 및 제 2 양자화 값이 하나의 파라미터를 양자화한 값임을 나타내는 일 예를 나타내는 도면이다.FIG. 9 is a diagram illustrating an example in which a first quantization value and a second quantization value are quantized values of one parameter using a tag bit.

뉴럴 네트워크 장치는 제 1 양자화 값 및 제 2 양자화 값이 하나의 파라미터를 양자화한 값임을 나타내기 위해, 제 1 양자화 값 및 제 2 양자화 값 각각에 태그 비트를 추가할 수 있다. The neural network apparatus may add a tag bit to each of the first quantization value and the second quantization value to indicate that the first quantization value and the second quantization value are quantized values of one parameter.

예를 들어, 뉴럴 네트워크 장치는 제 1 양자화 값에 연속된 제 2 양자화 값이 있음을 나타내는 제 1 태그 비트를 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가할 수 있다. 또한, 제 2 양자화 값에 연속된 양자화 값이 없음을 나타내는 제 2 태그 비트를 제 2 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가할 수 있다. 제 1 태그 비트가 1일 때 제 2 태그 비트는 0일 수 있으나 이에 제한되는 것은 아니며, 제 1 태그 비트가 0일 때 제 2 태그 비트는 1일 수 있다.For example, the neural network device may add a first tag bit indicating that there is a second quantization value consecutive to the first quantization value, before the first bit or after the last bit among the bits indicating the first quantization value. have. In addition, a second tag bit indicating that there is no consecutive quantization value to the second quantization value may be added before the first bit or after the last bit among bits indicating the second quantization value. When the first tag bit is 1, the second tag bit may be 0, but is not limited thereto. When the first tag bit is 0, the second tag bit may be 1.

도 9를 참조하면, 제 1 태그 비트 및 제 2 태그 비트 중 어느 하나는 양자화 값들 각각을 나타내는 비트들 중 첫 번째 비트의 앞에 추가될 수 있다. 이 때, 제 1 태그 비트는 1에 해당하고, 제 2 태그 비트는 0에 해당할 수 있다. 양자화 값 q[n-1], q[n]2 및 q[n+1] 각각을 나타내는 비트들 중 첫 번째 비트의 앞에는 제 2 태그 비트에 해당하는 0이 추가되어 있으므로, q[n-1], q[n]2 및 q[n+1] 각각에는 연속된 양자화 값이 없음을 알 수 있다. 한편, q[n]1을 나타내는 비트들 중 첫 번째 비트의 앞에는 제 1 태그 비트에 해당하는 1이 추가되어 있으므로, q[n]1에는 연속된 양자화 값이 있음을 알 수 있다. 따라서, q[n]1 및 q[n]2은 연속적으로 위치하여 그룹핑된 값에 해당하고, 그룹핑된 값은 하나의 파라미터를 양자화한 값임을 나타낼 수 있다. Referring to FIG. 9, any one of the first tag bit and the second tag bit may be added before the first bit of bits representing each of quantization values. In this case, the first tag bit may correspond to 1, and the second tag bit may correspond to 0. Since 0 corresponding to the second tag bit is added in front of the first bit among the bits representing each of the quantization values q[n-1], q[n]2, and q[n+1], q[n-1] ], q[n]2, and q[n+1] respectively have no consecutive quantization values. Meanwhile, since 1 corresponding to the first tag bit is added in front of the first bit among the bits representing q[n]1, it can be seen that q[n]1 has a continuous quantization value. Accordingly, q[n]1 and q[n]2 are consecutively positioned to correspond to grouped values, and the grouped values may represent quantized values of one parameter.

일 예로써, 제 1 양자화 값이 00001이고 제 2 양자화 값이 11100인 경우, 00001을 나타내는 비트들 중 첫 번째 비트의 앞에는 제 1 태그 비트에 해당하는 1을 추가하고, 11100을 나타내는 비트들 중 첫 번째 비트의 앞에는 제 2 태그 비트에 해당하는 0을 추가할 수 있다. 이를 통해, 제 1 양자화 값 00001 및 제 2 양자화 값 11100는 그룹핑되어 하나의 파라미터를 양자화한 값임을 나타낼 수 있다.As an example, when the first quantization value is 00001 and the second quantization value is 11100, 1 corresponding to the first tag bit is added to the front of the first bit among bits representing 00001, and the first of the bits representing 11100 0 corresponding to the second tag bit may be added in front of the th bit. Through this, the first quantization value 00001 and the second quantization value 11100 may be grouped to indicate that one parameter is quantized.

도 10은 코드 값을 이용하여 제 1 양자화 값 및 제 2 양자화 값이 하나의 파라미터를 양자화한 값임을 나타내는 일 예를 나타내는 도면이다.10 is a diagram illustrating an example in which a first quantization value and a second quantization value are quantized values of one parameter using a code value.

뉴럴 네트워크 장치는 제 1 양자화 값 및 제 2 양자화 값이 하나의 파라미터를 양자화한 값임을 나타내기 위해, 특정 코드 값을 추가할 수 있다. 코드 값은 제 1 양자화 값 또는 제 2 양자화 값과 동일한 수의 비트들로 구성될 수 있으나, 이에 제한되는 것은 아니다. The neural network apparatus may add a specific code value to indicate that the first quantization value and the second quantization value are quantized values of one parameter. The code value may be composed of the same number of bits as the first quantization value or the second quantization value, but is not limited thereto.

예를 들어, 뉴럴 네트워크 장치는 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 및 제 2 양자화 값을 나타내는 비트들 중 마지막 비트의 뒤 중 어느 하나에, 제 1 양자화 값 및 상기 제 2 양자화 값이 연속된 값임을 나타내는 코드 값을 추가할 수 있다.For example, the neural network apparatus may include a first quantization value and the second quantization value in any one of bits before a first bit among bits representing a first quantization value and after a last bit among bits representing a second quantization value. A code value indicating that the value is a continuous value can be added.

도 10을 참조하면, 코드 값은 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞에 추가될 수 있다. 양자화 값 q[n-1], q[n]2 및 q[n+1] 각각을 나타내는 비트들 중 첫 번째 비트의 앞에는 코드 값이 추가되지 않았으므로, q[n-1], q[n]2 및 q[n+1] 각각에는 연속된 양자화 값이 없음을 알 수 있다. 한편, q[n]1을 나타내는 비트들 중 첫 번째 비트의 앞에는 코드 값이 추가되어 있으므로, q[n]1에는 연속된 양자화 값이 있음을 알 수 있다. 따라서, q[n]1 및 q[n]2은 연속적으로 위치하여 그룹핑된 값에 해당하고, 그룹핑된 값은 하나의 파라미터를 양자화한 값임을 나타낼 수 있다.Referring to FIG. 10, a code value may be added before the first bit among bits representing a quantization value. Since a code value is not added in front of the first bit among the bits representing each of the quantization values q[n-1], q[n]2, and q[n+1], q[n-1], q[n It can be seen that there are no consecutive quantization values for each of ]2 and q[n+1]. Meanwhile, since a code value is added in front of the first bit among the bits representing q[n]1, it can be seen that q[n]1 has a continuous quantization value. Accordingly, q[n]1 and q[n]2 are consecutively positioned to correspond to grouped values, and the grouped values may represent quantized values of one parameter.

일 예로써, 제 1 양자화 값이 00001이고 제 2 양자화 값이 11100인 경우, 00001을 나타내는 비트들 중 첫 번째 비트의 앞에 코드값(-M)을 추가할 수 있다. 이를 통해, 제 1 양자화 값 00001 및 제 2 양자화 값 11100는 그룹핑되어 하나의 파라미터를 양자화한 값임을 나타낼 수 있다.As an example, when the first quantization value is 00001 and the second quantization value is 11100, a code value (-M) may be added in front of the first bit among bits representing 00001. Through this, the first quantization value 00001 and the second quantization value 11100 may be grouped to indicate that one parameter is quantized.

도 11은 뉴럴 네트워크 장치가 파라미터를 양자화하는 방법의 일 예를 설명하기 위한 흐름도이다. 11 is a flowchart illustrating an example of a method for quantizing a parameter by a neural network device.

1110 단계에서, 뉴럴 네트워크 장치는 초기 조건으로써 k=1, δ=x, q1=0으로 설정할 수 있다. x 는 뉴럴 네트워크 장치가 양자화하고자 하는 파라미터의 실제값에 해당할 수 있다.In step 1110, the neural network device may set k=1, δ=x, and q1=0 as initial conditions. x may correspond to an actual value of a parameter to be quantized by the neural network device.

1120 단계에서, 뉴럴 네트워크 장치는 k 에 해당하는 값이 L보다 큰 지 판단할 수 있다. L은 파라미터를 복수의 양자화 값들이 그룹핑된 값으로 양자화하는 경우, 최대로 그룹핑될 수 있는 양자화 값들의 개수에 해당할 수 있다. k에 해당하는 값이 L보다 크지 않은 경우에는 1130 단계로 진행한다. k에 해당하는 값이 L보다 큰 경우에는 1180 단계로 진행한다. In step 1120, the neural network device may determine whether a value corresponding to k is greater than L. L may correspond to the number of quantization values that can be grouped to a maximum when a parameter is quantized into a value in which a plurality of quantization values are grouped. If the value corresponding to k is not greater than L, the process proceeds to step 1130. If the value corresponding to k is greater than L, the process proceeds to step 1180.

1130 단계에서, 뉴럴 네트워크 장치는 δ에 해당하는 값이 0인지 여부를 판단할 수 있다. δ 에 해당하는 값이 0인 경우에는 1140 단계로 진행한다. δ 에 해당하는 값이 0이 아닌 경우에는 1180 단계로 진행한다.In step 1130, the neural network device may determine whether a value corresponding to δ is 0. If the value corresponding to δ is 0, the process proceeds to step 1140. If the value corresponding to δ is not 0, the process proceeds to step 1180.

1140 단계에서, 뉴럴 네트워크 장치는 로그 양자화를 수행함으로써 양자화 값 qk를 결정할 수 있다. qk는 하기 수학식 3에 의해 결정될 수 있다.In step 1140, the neural network device may determine the quantization value qk by performing log quantization. qk may be determined by Equation 3 below.

Figure pat00017
Figure pat00017

상기 수학식 3에서

Figure pat00018
은 δ의 부호에 따라 1 또는 -1로 결정될 수 있고,
Figure pat00019
는 δ의 절대값에 해당하며,
Figure pat00020
Figure pat00021
에 해당하는 값을 소수점 첫째 자리에서 반올림한 값에 해당할 수 있다.In Equation 3 above
Figure pat00018
May be determined as 1 or -1 depending on the sign of δ,
Figure pat00019
Corresponds to the absolute value of δ,
Figure pat00020
silver
Figure pat00021
It may correspond to a value that is rounded to the first decimal place.

1150 단계에서, 뉴럴 네트워크 장치는 파라미터의 실제값 및 양자화 값 q1 내지 qk가 그룹핑된 값을 역양자화한 값 간의 오차를 산출할 수 있다. 오차는 하기 수학식 4에 의해 결정될 수 있다. In step 1150, the neural network apparatus may calculate an error between an actual value of a parameter and a value obtained by inverse quantization of a grouped value of the quantization values q1 to qk. The error may be determined by Equation 4 below.

Figure pat00022
Figure pat00022

상기 수학식 4에서

Figure pat00023
는 양자화 값 q1 내지 qk가 그룹핑된 값을 역양자화한 값에 해당할 수 있고,
Figure pat00024
Figure pat00025
의 절대값에 해당할 수 있다. 한편, 복수의 양자화 값들이 그룹핑된 값을 역양자화하는 것에 관해서는 도 12에서 후술한다. In Equation 4 above
Figure pat00023
May correspond to a value obtained by inverse quantization of a grouped value of quantization values q1 to qk,
Figure pat00024
silver
Figure pat00025
It can correspond to the absolute value of Meanwhile, inverse quantization of a grouped value of a plurality of quantization values will be described later in FIG. 12.

1160 단계에서, 뉴럴 네트워크 장치는 δ에 해당하는 값이 임계값 O보다 큰 지 판단할 수 있다. δ 에 해당하는 값이 임계값 O보다 큰 경우에는 1170 단계로 진행한다. δ 에 해당하는 값이 임계값 O보다 크지 않은 경우에는 1180 단계로 진행한다.In step 1160, the neural network device may determine whether a value corresponding to δ is greater than a threshold value O. If the value corresponding to δ is greater than the threshold value O, the process proceeds to step 1170. If the value corresponding to δ is not greater than the threshold value O, the process proceeds to step 1180.

1170 단계에서, 뉴럴 네트워크 장치는 k 에 해당하는 값을 1만큼 증가시킬 수 있다. In step 1170, the neural network device may increase the value corresponding to k by 1.

1180 단계에서, 뉴럴 네트워크 장치는 최종적으로 파라미터를 양자화 값 q1 내지 qk가 그룹핑된 값으로 양자화할 수 있다. In step 1180, the neural network apparatus may finally quantize the parameter to a value obtained by grouping the quantization values q1 to qk.

도 12는 뉴럴 네트워크 장치가 파라미터를 역양자화하는 방법의 일 예를 설명하기 위한 흐름도이다.12 is a flowchart illustrating an example of a method of inverse quantizing a parameter by a neural network device.

1210 단계에서, 뉴럴 네트워크 장치는 초기 조건으로써 k=1,

Figure pat00026
으로 설정할 수 있다. 이 때, 역양자화의 대상이 되는 값은 양자화 값 q1 내지 qn이 그룹핑된 값일 수 있다.
Figure pat00027
는 그룹핑된 값을 역양자화한 값에 해당할 수 있다. In step 1210, the neural network device k=1 as an initial condition,
Figure pat00026
Can be set to In this case, a value to be subjected to inverse quantization may be a value obtained by grouping quantization values q1 to qn.
Figure pat00027
May correspond to a value obtained by inverse quantization of the grouped values.

1220 단계에서, 뉴럴 네트워크 장치는 qk에 해당하는 값이 0인지 여부를 판단할 수 있다. qk에 해당하는 값이 0이 아닌 경우에는 1230 단계로 진행한다. qk에 해당하는 값이 0인 경우에는 1240 단계로 진행한다. In step 1220, the neural network device may determine whether a value corresponding to qk is 0. If the value corresponding to qk is not 0, the process proceeds to step 1230. If the value corresponding to qk is 0, the process proceeds to step 1240.

1230 단계에서, 뉴럴 네트워크 장치는 역양자화를 수행함으로써 역양자화 값

Figure pat00028
를 결정할 수 있다.
Figure pat00029
는 하기 수학식 5에 의해 결정될 수 있다.In step 1230, the neural network device performs inverse quantization to determine the inverse quantization value.
Figure pat00028
Can be determined.
Figure pat00029
May be determined by Equation 5 below.

Figure pat00030
Figure pat00030

상기 수학식 5에서

Figure pat00031
은 δ의 부호에 따라 1 또는 -1로 결정될 수 있다. 양자화 값 q1 내지 qn이 그룹핑된 값을 역양자화한 값
Figure pat00032
는 양자화 값 q1 내지 qn 각각을 역양자화한 값을 누적함으로써 결정될 수 있다.In Equation 5 above
Figure pat00031
May be determined as 1 or -1 depending on the sign of δ. Inverse quantization of the grouped values of quantization values q1 to qn
Figure pat00032
May be determined by accumulating values obtained by inverse quantization of each of the quantization values q1 to qn.

1240 단계에서, 뉴럴 네트워크 장치는 k에 해당하는 값이 n인 지 여부를 판단할 수 있다. k 에 해당하는 값이 n인 경우에는 1260 단계로 진행한다. k 에 해당하는 값이 n이 아닌 경우에는 1250 단계로 진행한다.In step 1240, the neural network device may determine whether a value corresponding to k is n. If the value corresponding to k is n, the process proceeds to step 1260. If the value corresponding to k is not n, the process proceeds to step 1250.

1250 단계에서, 뉴럴 네트워크 장치는 k 에 해당하는 값을 1만큼 증가시킬 수 있다.In step 1250, the neural network device may increase the value corresponding to k by 1.

1260 단계에서, 뉴럴 네트워크 장치는 양자화 값 q1 내지 qn이 그룹핑된 값을 역양자화한 값으로써

Figure pat00033
를 출력할 수 있다.
Figure pat00034
는 양자화 값 q1 내지 qn 각각을 역양자화한 값을 누적한 값에 해당할 수 있다.In step 1260, the neural network device is a value obtained by inverse quantizing the grouped values of quantization values q1 to qn.
Figure pat00033
Can be printed.
Figure pat00034
May correspond to an accumulated value obtained by inverse quantization of each of the quantization values q1 to qn.

도 13은 파라미터를 양자화하는 방식에 따른 뉴럴 네트워크의 정확도를 비교한 도면이다.13 is a diagram comparing the accuracy of neural networks according to a method of quantizing parameters.

이미지 분류의 정확도를 산출하기 위한 뉴럴 네트워크의 모델은 AlexNet, SqueezeNet 및 VGG-S를 포함할 수 있다. 도 13을 참조하면, 선형 양자화 방식, 로그 양자화 방식 및 본 실시예에 따라 양자화 에러값이 임계값 이상인 경우에는 두 개 이상의 양자화 값으로 표현하는 로그 양자화 방식 각각이 적용되는 경우 뉴럴 네트워크에서의 분류 정확도(%)가 표시되어 있다. 한편, float 32b는 파라미터를 양자화하지 않은 경우를 나타낸다.  Models of neural networks for calculating the accuracy of image classification may include AlexNet, SqueezeNet, and VGG-S. Referring to FIG. 13, when a linear quantization method, a log quantization method, and a log quantization method expressed by two or more quantization values are applied when a quantization error value is greater than or equal to a threshold value according to the present embodiment, classification accuracy in a neural network (%) is indicated. On the other hand, float 32b indicates a case where the parameter is not quantized.

도 13에 따라, 기존의 로그 양자화 방식 대비 본 실시예에 따른 로그 양자화 방식을 적용하는 경우, 2% 내지 4% 정도 정확도가 향상됨을 알 수 있다.Referring to FIG. 13, it can be seen that when the log quantization method according to the present embodiment is applied compared to the conventional log quantization method, accuracy is improved by about 2% to 4%.

도 14는 MAC(Multiplication and Accumulation) 연산을 수행하는 연산 장치의 일 예를 나타내는 도면이다.14 is a diagram illustrating an example of a computing device that performs a multiplication and accumulation (MAC) operation.

뉴럴 네트워크 장치는 예를 들어 뉴럴 네트워크의 레이어에서 처리되는 웨이트 값들을 양자화하여 메모리에 저장할 수 있다. 이후, 뉴럴 네트워크 장치는 양자화된 웨이트 값들을 역양자화하여 입력 액티베이션 값들과 컨볼루션 연산을 수행할 수 있다. The neural network device may quantize weight values processed in a layer of a neural network and store them in a memory. Thereafter, the neural network apparatus may inverse quantize the quantized weight values to perform a convolution operation with input activation values.

이 때, 웨이트 값이 제 1 양자화 값 및 제 2 양자화 값이 그룹핑된 값으로 양자화된 경우 뉴럴 네트워크 장치는 그룹핑된 값을 역양자화하고, 그룹핑된 값을 역양자화한 값과 입력 액티베이션 값 간의 컨볼루션 연산을 수행할 수 있다. 한편, 뉴럴 네트워크 장치는 제 1 양자화 값을 역양자화한 값인 제 1 역양자화 값 및 제 2 양자화 값을 역양자화한 값인 제 2 역양자화 값 각각을 산출하고, 제 1 역양자화 값 및 제 2 역양자화 값을 더함으로써 그룹핑된 값을 역양자화할 수 있다. In this case, when the weight value is quantized into a grouped value of the first quantization value and the second quantization value, the neural network device dequantizes the grouped value, and convolutions between the dequantized value of the grouped value and the input activation value. Can perform operations. Meanwhile, the neural network device calculates each of a first inverse quantization value that is a value obtained by inverse quantization of the first quantization value and a second inverse quantization value that is a value obtained by inverse quantization of the second quantization value Grouped values can be inverse quantized by adding values.

이에 따라, 제 1 양자화 값을 역양자화한 값인 제 1 역양자화 값 및 제 2 양자화 값을 역양자화한 값인 제 2 역양자화 값 각각은 동일한 입력 액티베이션 값과 연산이 수행되어야 한다. Accordingly, the first inverse quantization value, which is a value obtained by inverse quantization of the first quantization value, and the second inverse quantization value, which is a value obtained by inverse quantization of the second quantization value, must perform the same input activation value and operation.

도 14는 웨이트 값들이 태그 비트를 이용하여 양자화된 경우 MAC 연산을 수행하는 연산 장치이며, q는 웨이트 값들이 양자화된 값을 나타내고 X는 입력 액티베이션 값을 나타낸다. MAC 연산을 수행하는 연산 장치는 태그 비트가 1인 경우 이를 MUX(Multiplexer) 선택 신호로 사용하여 전 사이틀(cycle)의 입력 액티베이션 값 X가 계속 연산에 이용되도록 할 수 있다. 이 때, 양자화 값에 추가된 태그 비트가 1인 경우에는 해당 양자화 값에 연속적으로 위치하는 또 다른 양자화 값이 있음을 나타낼 수 있다. 태그 비트가 0인 경우에는, 연속적으로 위치하는 양자화 값이 없으므로 전 사이클의 입력 액티베이션 값 X와는 다른 새로운 입력 액티베이션 값 X가 입력되어 연산이 수행될 수 있다.14 is a computing device that performs a MAC operation when weight values are quantized using tag bits, where q represents a quantized value of weight values and X represents an input activation value. When the tag bit is 1, the computing device performing the MAC operation may use this as a multiplexer (MUX) selection signal so that the input activation value X of the previous cycle is continuously used for calculation. In this case, when the tag bit added to the quantization value is 1, it may indicate that there is another quantization value continuously positioned in the corresponding quantization value. When the tag bit is 0, since there is no quantization value positioned continuously, a new input activation value X different from the input activation value X of the previous cycle may be input to perform an operation.

도 15는 MAC(Multiplication and Accumulation) 연산을 수행하는 연산 장치의 다른 예를 나타내는 도면이다.15 is a diagram illustrating another example of a computing device that performs a multiplication and accumulation (MAC) operation.

도 15는 웨이트 값들이 코드값을 이용하여 양자화된 경우 MAC 연산을 수행하는 연산 장치이며, 마찬가지로 q는 웨이트 값들이 양자화된 값을 나타내고 X는 입력 액티베이션 값을 나타낸다. MAC 연산을 수행하는 연산 장치는 코드값이 입력된 경우 이를 MUX(Multiplexer) 선택 신호로 사용할 수 있다. 이에 따라, 코드값 이후에 연속적으로 입력되는 제 1 양자화 값 및 제 2 양자화 값에 대해서는 동일한 입력 액티베이션 값 X가 계속 연산에 이용되도록 할 수 있다. 한편, 코드값 및 입력 액티베이션 값 X 간의 연산 결과는 결과값 Y에 누적되지 않도록 할 수 있다.FIG. 15 is a computing device that performs MAC operation when weight values are quantized using code values. Likewise, q represents a quantized value of weight values and X represents an input activation value. When a code value is input, the computing device performing MAC operation may use it as a multiplexer (MUX) selection signal. Accordingly, for the first quantization value and the second quantization value continuously input after the code value, the same input activation value X can be continuously used for calculation. Meanwhile, the calculation result between the code value and the input activation value X may not be accumulated in the result value Y.

도 16은 일 실시예에 따른 전자 시스템을 나타내는 블록도이다.16 is a block diagram illustrating an electronic system according to an exemplary embodiment.

도 16을 참고하면, 전자 시스템(1600)은 뉴럴 네트워크를 기초로 입력 데이터를 실시간으로 분석하여 유효한 정보를 추출하고, 추출된 정보를 기초로 상황 판단을 하거나 또는 전자 시스템(1600)이 탑재되는 전자 디바이스의 구성들을 제어할 수 있다. 예컨대 전자 시스템(1600)은 드론(drone), 첨단 운전자 보조 시스템(Advanced Drivers Assistance System; ADAS) 등과 같은 로봇 장치, 스마트 TV, 스마트폰, 의료 디바이스, 모바일 디바이스, 영상 표시 디바이스, 계측 디바이스, IoT 디바이스 등에 적용될 수 있으며, 이 외에도 다양한 종류의 전자 디바이스들 중 적어도 하나에 탑재될 수 있다. Referring to FIG. 16, the electronic system 1600 extracts valid information by analyzing input data in real time based on a neural network, and makes a situation determination based on the extracted information, or an electronic system on which the electronic system 1600 is mounted. You can control the configuration of the device. For example, the electronic system 1600 is a robot device such as a drone, an advanced driver assistance system (ADAS), a smart TV, a smart phone, a medical device, a mobile device, an image display device, a measurement device, an IoT device. It may be applied to, etc., and may be mounted on at least one of various types of electronic devices.

전자 시스템(1600)은 CPU(1610), RAM(1620), 뉴럴 네트워크 장치(1630), 메모리(1640), 센서 모듈(1650) 및 통신 모듈(1660)을 포함할 수 있다. 전자 시스템(1600)은 입출력 모듈, 보안 모듈, 전력 제어 장치 등을 더 포함할 수 있다. 전자 시스템(1600)의 하드웨어 구성들 중 일부는 적어도 하나의 반도체 칩에 탑재될 수 있다. 뉴럴 네트워크 장치(1630)는 앞서 설명된 뉴럴 네트워크 전용 하드웨어 가속기 자체 또는 이를 포함하는 장치일 수 있다.The electronic system 1600 may include a CPU 1610, a RAM 1620, a neural network device 1630, a memory 1640, a sensor module 1650, and a communication module 1660. The electronic system 1600 may further include an input/output module, a security module, and a power control device. Some of the hardware components of the electronic system 1600 may be mounted on at least one semiconductor chip. The neural network device 1630 may be the above-described neural network dedicated hardware accelerator itself or a device including the same.

CPU(1610)는 전자 시스템(1600)의 전반적인 동작을 제어한다. CPU(1610)는 하나의 프로세서 코어(Single Core)를 포함하거나, 복수의 프로세서 코어들(Multi-Core)을 포함할 수 있다. CPU(1610)는 메모리(1640)에 저장된 프로그램들 및/또는 데이터를 처리 또는 실행할 수 있다. 일 실시예에 있어서, CPU(1610)는 메모리(1640)에 저장된 프로그램들을 실행함으로써, 뉴럴 네트워크 장치(1630)의 기능을 제어할 수 있다. CPU(1610)는 CPU, GPU, AP 등으로 구현될 수 있다.The CPU 1610 controls the overall operation of the electronic system 1600. The CPU 1610 may include one processor core (Single Core), or may include a plurality of processor cores (Multi-Core). The CPU 1610 may process or execute programs and/or data stored in the memory 1640. In an embodiment, the CPU 1610 may control functions of the neural network device 1630 by executing programs stored in the memory 1640. The CPU 1610 may be implemented as a CPU, GPU, or AP.

RAM(1620)은 프로그램들, 데이터, 또는 명령들(instructions)을 일시적으로 저장할 수 있다. 예컨대 메모리(1640)에 저장된 프로그램들 및/또는 데이터는 CPU(1610)의 제어 또는 부팅 코드에 따라 RAM(1620)에 일시적으로 저장될 수 있다. RAM(1620)은 DRAM(Dynamic RAM) 또는 SRAM(Static RAM) 등의 메모리로 구현될 수 있다.The RAM 1620 may temporarily store programs, data, or instructions. For example, programs and/or data stored in the memory 1640 may be temporarily stored in the RAM 1620 according to the control of the CPU 1610 or a boot code. The RAM 1620 may be implemented as a memory such as dynamic RAM (DRAM) or static RAM (SRAM).

뉴럴 네트워크 장치(1630)는 수신되는 입력 데이터를 기초로 뉴럴 네트워크의 연산을 수행하고, 수행 결과를 기초로 정보 신호를 생성할 수 있다. 뉴럴 네트워크는 Convolutional Neural Networks(CNN), Recurrent Neural Networks(RNN), Deep Belief Networks, Restricted Boltzman Machines 등을 포함할 수 있으나 이에 제한되지 않는다. 뉴럴 네트워크 장치(1630)는 앞서 설명된 고정 소수점 타입으로 양자화된 뉴럴 네트워크를 이용하여 처리를 수행하는 하드웨어로서, 앞서 설명된 뉴럴 네트워크 전용 하드웨어 가속기에 해당될 수 있다.The neural network apparatus 1630 may perform an operation of a neural network based on the received input data, and may generate an information signal based on a result of the execution. The neural network may include, but is not limited to, Convolutional Neural Networks (CNN), Recurrent Neural Networks (RNN), Deep Belief Networks, Restricted Boltzman Machines, and the like. The neural network device 1630 is hardware that performs processing using a neural network quantized to the fixed-point type described above, and may correspond to the aforementioned hardware accelerator dedicated to a neural network.

정보 신호는 음성 인식 신호, 사물 인식 신호, 영상 인식 신호, 생체 정보 인식 신호 등과 같은 다양한 종류의 인식 신호 중 하나를 포함할 수 있다. 예를 들어, 뉴럴 네트워크 장치(1630)는 비디오 스트림에 포함되는 프레임 데이터를 입력 데이터로서 수신하고, 프레임 데이터로부터 프레임 데이터가 나타내는 이미지에 포함된 사물에 대한 인식 신호를 생성할 수 있다. 그러나, 이에 제한되는 것은 아니며, 전자 시스템(1600)이 탑재된 전자 장치의 종류 또는 기능에 따라 뉴럴 네트워크 장치(1630)는 다양한 종류의 입력 데이터를 수신할 수 있고, 입력 데이터에 따른 인식 신호를 생성할 수 있다.The information signal may include one of various types of recognition signals such as a voice recognition signal, an object recognition signal, an image recognition signal, and a biometric information recognition signal. For example, the neural network apparatus 1630 may receive frame data included in a video stream as input data, and may generate a recognition signal for an object included in an image represented by the frame data from the frame data. However, the present invention is not limited thereto, and the neural network device 1630 may receive various types of input data according to the type or function of the electronic device on which the electronic system 1600 is mounted, and generates a recognition signal according to the input data. can do.

메모리(1640)는 데이터를 저장하기 위한 저장 장소로서, OS(Operating System), 각종 프로그램들, 및 각종 데이터를 저장할 수 있다. 실시예에 있어서, 메모리(1640)는 뉴럴 네트워크 장치(1630)의 연산 수행 과정에서 생성되는 중간 결과들, 예컨대 출력 피처 맵을 출력 피처 리스트 또는 출력 피처 매트릭스 형태로 저장할 수 있다. 실시예에 있어서, 메모리(1640)에는 압축된 출력 피처 맵이 저장될 수 있다. 또한, 메모리(1640)는 뉴럴 네트워크 장치(1630)에서 이용되는 양자화된 뉴럴 네트워크 데이터, 예컨대, 파라미터들, 웨이트 맵 또는 웨이트 리스트를 저장할 수 있다. The memory 1640 is a storage location for storing data, and may store an operating system (OS), various programs, and various data. In an embodiment, the memory 1640 may store intermediate results, such as an output feature map, generated in a process of performing an operation of the neural network device 1630 in the form of an output feature list or an output feature matrix. In an embodiment, the compressed output feature map may be stored in the memory 1640. In addition, the memory 1640 may store quantized neural network data used in the neural network apparatus 1630, for example, parameters, a weight map, or a weight list.

메모리(1640)는 DRAM일 수 있으나, 이에 한정되는 것은 아니다. 메모리(1640)는 휘발성 메모리 또는 불휘발성 메모리 중 적어도 하나를 포함할 수 있다. 불휘발성 메모리는 ROM, PROM, EPROM, EEPROM, 플래시 메모리, PRAM, MRAM, RRAM, FRAM 등을 포함한다. 휘발성 메모리는 DRAM, SRAM, SDRAM, PRAM, MRAM, RRAM, FeRAM 등을 포함한다. 실시예에 있어서, 메모리(1640)는 HDD, SSD, CF, SD, Micro-SD, Mini-SD, xD 또는 Memory Stick 중 적어도 하나를 포함할 수 있다. The memory 1640 may be DRAM, but is not limited thereto. The memory 1640 may include at least one of a volatile memory or a nonvolatile memory. Nonvolatile memory includes ROM, PROM, EPROM, EEPROM, flash memory, PRAM, MRAM, RRAM, FRAM, and the like. Volatile memory includes DRAM, SRAM, SDRAM, PRAM, MRAM, RRAM, FeRAM, and the like. In an embodiment, the memory 1640 may include at least one of HDD, SSD, CF, SD, Micro-SD, Mini-SD, xD, or Memory Stick.

센서 모듈(1650)은 전자 시스템(1600)이 탑재되는 전자 장치 주변의 정보를 수집할 수 있다. 센서 모듈(1650)은 전자 장치의 외부로부터 신호(예컨대 영상 신호, 음성 신호, 자기 신호, 생체 신호, 터치 신호 등)를 센싱 또는 수신하고, 센싱 또는 수신된 신호를 데이터로 변환할 수 있다. 이를 위해, 센서 모듈(1650)은 센싱 장치, 예컨대 마이크, 촬상 장치, 이미지 센서, 라이더(LIDAR; light detection and ranging) 센서, 초음파 센서, 적외선 센서, 바이오 센서, 및 터치 센서 등 다양한 종류의 센싱 장치 중 적어도 하나를 포함할 수 있다. The sensor module 1650 may collect information around an electronic device in which the electronic system 1600 is mounted. The sensor module 1650 may sense or receive a signal (eg, an image signal, an audio signal, a magnetic signal, a biometric signal, a touch signal, etc.) from the outside of the electronic device and convert the sensed or received signal into data. To this end, the sensor module 1650 is a sensing device such as a microphone, an imaging device, an image sensor, a light detection and ranging (LIDAR) sensor, an ultrasonic sensor, an infrared sensor, a bio sensor, and a touch sensor. It may include at least one of.

센서 모듈(1650)은 변환된 데이터를 뉴럴 네트워크 장치(1630)에 입력 데이터로서 제공할 수 있다. 예를 들어, 센서 모듈(1650)은 이미지 센서를 포함할 수 있으며, 전자 장치의 외부 환경을 촬영하여 비디오 스트림을 생성하고, 비디오 스트림의 연속하는 데이터 프레임을 뉴럴 네트워크 장치(1630)에 입력 데이터로서 순서대로 제공할 수 있다. 그러나 이에 제한되는 것은 아니며 센서 모듈(1650)은 다양한 종류의 데이터를 뉴럴 네트워크 장치(1630)에 제공할 수 있다. The sensor module 1650 may provide the converted data to the neural network device 1630 as input data. For example, the sensor module 1650 may include an image sensor, and generates a video stream by photographing an external environment of the electronic device, and sends a continuous data frame of the video stream to the neural network device 1630 as input data. Can be provided in order. However, the present invention is not limited thereto, and the sensor module 1650 may provide various types of data to the neural network device 1630.

통신 모듈(1660)은 외부 장치와 통신할 수 있는 다양한 유선 또는 무선 인터페이스를 구비할 수 있다. 예컨대 통신 모듈(1660)은 유선 근거리통신망(Local Area Network; LAN), Wi-fi(Wireless Fidelity)와 같은 무선 근거리 통신망 (Wireless Local Area Network; WLAN), 블루투스(Bluetooth)와 같은 무선 개인 통신망(Wireless Personal Area Network; WPAN), 무선 USB (Wireless Universal Serial Bus), Zigbee, NFC (Near Field Communication), RFID (Radio-frequency identification), PLC(Power Line communication), 또는 3G (3rd Generation), 4G (4th Generation), LTE (Long Term Evolution) 등 이동 통신망(mobile cellular network)에 접속 가능한 통신 인터페이스 등을 포함할 수 있다.The communication module 1660 may include various wired or wireless interfaces capable of communicating with external devices. For example, the communication module 1660 includes a wireless local area network (WLAN) such as a wired local area network (LAN), a wireless fidelity (Wi-fi), and a wireless personal communication network such as Bluetooth. Personal Area Network; WPAN), wireless USB (Wireless Universal Serial Bus), Zigbee, NFC (Near Field Communication), RFID (Radio-frequency identification), PLC (Power Line communication), or 3G (3rd Generation), 4G (4th) Generation), LTE (Long Term Evolution), and the like, a communication interface accessible to a mobile cellular network.

이하, 도 17을 참조하여 뉴럴 네트워크 장치(1630)를 보다 상세히 설명하기로 한다.Hereinafter, the neural network device 1630 will be described in more detail with reference to FIG. 17.

도 17은 뉴럴 네트워크 장치의 구성의 일 예를 도시한 블록도이다.17 is a block diagram illustrating an example of a configuration of a neural network device.

뉴럴 네트워크 장치(1700)는 PC(personal computer), 서버 디바이스, 모바일 디바이스, 임베디드 디바이스 등의 다양한 종류의 디바이스들로 구현될 수 있다. 예를 들어, 뉴럴 네트워크 장치(1700)는 뉴럴 네트워크를 이용한 음성 인식, 영상 인식, 영상 분류 등을 수행하는 스마트폰, 태블릿 디바이스, AR(Augmented Reality) 디바이스, IoT(Internet of Things) 디바이스, 자율주행 자동차, 로보틱스, 의료기기 등으로 구현될 수 있으나, 이에 제한되지 않는다. 나아가서, 뉴럴 네트워크 장치(1700)는 위와 같은 디바이스에 탑재되는 전용 하드웨어 가속기(HW accelerator)에 해당될 수 있고, 뉴럴 네트워크 장치(1700)는 뉴럴 네트워크 구동을 위한 전용 모듈인 NPU(neural processing unit), TPU(Tensor Processing Unit), Neural Engine 등과 같은 하드웨어 가속기일 수 있으나, 이에 제한되지 않는다.The neural network apparatus 1700 may be implemented as various types of devices such as a personal computer (PC), a server device, a mobile device, and an embedded device. For example, the neural network device 1700 is a smartphone, tablet device, Augmented Reality (AR) device, Internet of Things (IoT) device, and autonomous driving that perform voice recognition, image recognition, and image classification using a neural network. It may be implemented in automobiles, robotics, medical devices, etc., but is not limited thereto. Furthermore, the neural network apparatus 1700 may correspond to a dedicated hardware accelerator (HW accelerator) mounted in the above device, and the neural network apparatus 1700 is a neural processing unit (NPU), which is a dedicated module for driving a neural network, It may be a hardware accelerator such as a Tensor Processing Unit (TPU) or a Neural Engine, but is not limited thereto.

도 17을 참조하면, 뉴럴 네트워크 장치(1700)는 프로세서(1710) 및 메모리(1730)를 포함한다. 도 17에 도시된 뉴럴 네트워크 장치(1700)에는 본 실시예들과 관련된 구성요소들만이 도시되어 있다. 따라서, 뉴럴 네트워크 장치(1700)에는 도 17에 도시된 구성요소들 외에 다른 범용적인 구성요소들이 더 포함될 수 있음은 당해 기술분야의 통상의 기술자에게 자명하다.Referring to FIG. 17, the neural network device 1700 includes a processor 1710 and a memory 1730. In the neural network device 1700 illustrated in FIG. 17, only components related to the present embodiments are shown. Therefore, it is apparent to those skilled in the art that the neural network apparatus 1700 may further include other general-purpose components in addition to the components shown in FIG. 17.

프로세서(1710)는 뉴럴 네트워크의 레이어에서 처리되는 입력 액티베이션 값들 및 웨이트 값들 중 적어도 하나를 포함하는 파라미터를 양자화할 수 있다. The processor 1710 may quantize a parameter including at least one of input activation values and weight values processed in a layer of a neural network.

먼저, 프로세서(1710)는 파라미터에 대한 로그 양자화(log quantization)를 수행함으로써 제 1 양자화 값을 결정할 수 있다. First, the processor 1710 may determine a first quantization value by performing log quantization on a parameter.

또한, 프로세서(1710)는 제 1 양자화 값에 대한 역양자화(dequantization)에 의해 획득된 제 1 역양자화 값 및 파라미터 간의 오차와 임계값을 비교할 수 있다. 이 때, 임계값은, 뉴럴 네트워크의 인식률 및 파라미터의 양자화에 따른 데이터의 크기 간의 트레이드-오프 관계에 기초하여 결정될 수 있다.Also, the processor 1710 may compare an error and a threshold value between a first inverse quantization value and a parameter obtained by dequantization of the first quantization value. In this case, the threshold may be determined based on a trade-off relationship between a recognition rate of a neural network and a size of data according to quantization of a parameter.

프로세서(1710)는 비교 결과 오차가 임계값보다 큰 경우, 오차에 대한 로그 양자화를 수행함으로써 제 2 양자화 값을 결정할 수 있다. 한편, 오차가 임계값보다 작은 경우에는 파라미터를 제 1 양자화 값으로 양자화할 수 있다. When the error as a result of the comparison is greater than the threshold value, the processor 1710 may determine the second quantization value by performing log quantization on the error. Meanwhile, when the error is less than the threshold value, the parameter may be quantized to the first quantization value.

최종적으로, 프로세서(1710)는 파라미터를 제 1 양자화 값 및 제 2 양자화 값이 그룹핑된 값으로 양자화할 수 있다. 또한, 프로세서(1710)는 제 1 양자화 값 및 제 2 양자화 값이 하나의 파라미터를 양자화한 값임을 내기 위해, 제 1 양자화 값 및 제 2 양자화 값 각각에 태그 비트를 추가할 수 있다. 예를 들어, 프로세서(1710)는 제 1 양자화 값에 연속된 제 2 양자화 값이 있음을 나타내는 제 1 태그 비트를 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가하고, 제 2 양자화 값에 연속된 양자화 값이 없음을 나타내는 제 2 태그 비트를 제 2 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가할 수 있다. 또는, 프로세서(1710)는 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 및 제 2 양자화 값을 구성하는 비트들 중 마지막 비트의 뒤 중 어느 하나에, 제 1 양자화 값 및 제 2 양자화 값이 연속된 값임을 나타내는 코드 값을 추가할 수도 있다.Finally, the processor 1710 may quantize the parameter into a value obtained by grouping the first quantization value and the second quantization value. In addition, the processor 1710 may add a tag bit to each of the first quantization value and the second quantization value to indicate that the first quantization value and the second quantization value are quantized values of one parameter. For example, the processor 1710 adds a first tag bit indicating that there is a second quantization value consecutive to the first quantization value, before the first bit or after the last bit among the bits indicating the first quantization value. , A second tag bit indicating that there is no consecutive quantization value in the second quantization value may be added before the first bit or after the last bit among bits indicating the second quantization value. Alternatively, the processor 1710 may include a first quantization value and a second quantization value in any one of the bits indicating the first quantization value before the first bit and after the last bit of the bits constituting the second quantization value You can also add a code value indicating that this is a continuous value.

한편, 프로세서(1710)는 뉴럴 네트워크의 레이어에서 처리되는 웨이트 값들을 양자화한 경우에 제 1 양자화 값 및 제 2 양자화 값이 그룹핑된 값을 역양자화하고, 역양자화한 값과 입력 액티베이션 값들간의 컨볼루션(convolution) 연산을 수행할 수 있다. 예를 들어, 프로세서는 제 1 양자화 값을 역양자화한 값인 제 1 역양자화 값 및 제 2 양자화 값을 역양자화한 값인 제 2 역양자화 값 각각을 산출하고, 제 1 역양자화 값 및 제 2 역양자화 값을 더하여 그룹핑된 값을 역양자화 값을 획득할 수 있다. Meanwhile, when the weight values processed in the layer of the neural network are quantized, the processor 1710 dequantizes the grouped value of the first quantization value and the second quantization value, and convolutions between the inverse quantized value and the input activation values. You can perform a convolution operation. For example, the processor calculates a first inverse quantization value that is a value obtained by inverse quantization of a first quantization value and a second inverse quantization value that is a value obtained by inverse quantization of the second quantization value, and calculates a first inverse quantization value and a second inverse quantization value. By adding the values, the grouped values may be inverse quantized.

프로세서(1710)는 뉴럴 네트워크 장치(1700) 내에 구비된 CPU(central processing unit), GPU(graphics processing unit), AP(application processor) 등으로 구현될 수 있으나, 이에 제한되지 않는다.The processor 1710 may be implemented with a central processing unit (CPU), a graphics processing unit (GPU), an application processor (AP), etc. included in the neural network device 1700, but is not limited thereto.

메모리(1730)는 뉴럴 네트워크 장치(1700)에서 처리된 데이터들 및 처리될 데이터들을 저장할 수 있다. 예를 들어, 메모리(1730)는 레이어에서 처리되는 입력 액티베이션 값들 및 웨이트 값들 중 적어도 하나를 포함하는 파라미터, 제 1 양자화 값 및 제 2 양자화 값 등을 저장할 수 있다. 메모리(1730)는 DRAM(dynamic random access memory), SRAM(static random access memory) 등과 같은 RAM(random access memory), ROM(read-only memory), EEPROM(electrically erasable programmable read-only memory), CD-ROM, 블루레이 또는 다른 광학 디스크 스토리지, HDD(hard disk drive), SSD(solid state drive), 또는 플래시 메모리일 수 있으나, 이에 한정되지 않는다.The memory 1730 may store data processed by the neural network device 1700 and data to be processed. For example, the memory 1730 may store a parameter including at least one of input activation values and weight values processed in a layer, a first quantization value, and a second quantization value. The memory 1730 includes a random access memory (RAM) such as dynamic random access memory (DRAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), and CD- ROM, Blu-ray or other optical disk storage, hard disk drive (HDD), solid state drive (SSD), or flash memory, but is not limited thereto.

한편, 상술한 방법은 컴퓨터에서 실행될 수 있는 프로그램으로 작성 가능하고, 컴퓨터로 읽을 수 있는 기록매체를 이용하여 상기 프로그램을 동작시키는 범용 디지털 컴퓨터에서 구현될 수 있다. 또한, 상술한 방법에서 사용된 데이터의 구조는 컴퓨터로 읽을 수 있는 기록매체에 여러 수단을 통하여 기록될 수 있다. 상기 컴퓨터로 읽을 수 있는 기록매체는 마그네틱 저장매체(예를 들면, 롬, 램, USB, 플로피 디스크, 하드 디스크 등), 광학적 판독 매체(예를 들면, 시디롬, 디브이디 등)와 같은 저장매체를 포함한다.Meanwhile, the above-described method can be written as a program that can be executed on a computer, and can be implemented in a general-purpose digital computer that operates the program using a computer-readable recording medium. In addition, the structure of the data used in the above-described method can be recorded on a computer-readable recording medium through various means. The computer-readable recording medium includes a storage medium such as a magnetic storage medium (e.g., ROM, RAM, USB, floppy disk, hard disk, etc.), and an optical reading medium (e.g., CD-ROM, DVD, etc.). do.

이제까지 바람직한 실시예들을 중심으로 살펴보았다. 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자는 상기된 기재의 본질적인 특성에서 벗어나지 않는 범위에서 변형된 형태로 구현될 수 있음을 이해할 수 있을 것이다. 그러므로 개시된 실시예들은 한정적인 관점이 아니라 설명적인 관점에서 고려되어야 하며, 권리 범위는 전술한 설명이 아니라 특허청구범위에 나타나 있으며, 그와 동등한 범위 내에 있는 모든 차이점을 포함하는 것으로 해석되어야 할 것이다.We have looked at the center of the preferred embodiments so far. Those of ordinary skill in the art to which the present invention pertains will appreciate that it may be implemented in a modified form without departing from the essential characteristics of the above-described substrate. Therefore, the disclosed embodiments should be considered from a descriptive point of view rather than a limiting point of view, and the scope of the rights is indicated in the claims rather than the above description, and should be interpreted as including all differences within the scope equivalent thereto.

Claims (19)

뉴럴 네트워크에서 파라미터를 양자화하는 방법에 있어서,
뉴럴 네트워크의 레이어에서 처리되는 입력 액티베이션 값들 및 웨이트 값들 중 적어도 하나를 포함하는 파라미터에 대한 로그 양자화(log quantization)를 수행함으로써 제 1 양자화 값을 결정하는 단계;
상기 제 1 양자화 값에 대한 역양자화(dequantization)에 의해 획득된 제 1 역양자화 값 및 상기 파라미터 간의 오차와 임계값을 비교하는 단계;
상기 비교 결과 상기 오차가 상기 임계값보다 큰 경우, 상기 오차에 대한 로그 양자화를 수행함으로써 제 2 양자화 값을 결정하는 단계; 및
상기 파라미터를 상기 제 1 양자화 값 및 상기 제 2 양자화 값이 그룹핑된 값으로 양자화하는 단계를 포함하는 방법.
In a method of quantizing parameters in a neural network,
Determining a first quantization value by performing log quantization on a parameter including at least one of input activation values and weight values processed in a layer of the neural network;
Comparing an error and a threshold value between a first inverse quantization value obtained by dequantization of the first quantization value and the parameter;
Determining a second quantization value by performing log quantization on the error when the error is greater than the threshold value as a result of the comparison; And
And quantizing the parameter into a grouped value of the first quantization value and the second quantization value.
제 1 항에 있어서,
상기 제 1 양자화 값을 결정하는 단계는,
상기 복수의 양자화 레벨들 중에서 상기 파라미터에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 상기 제 1 양자화 값을 결정하고,
상기 제 2 양자화 값을 결정하는 단계는,
상기 복수의 양자화 레벨들 중에서 상기 오차에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 상기 제 2 양자화 값을 결정하는 방법.
The method of claim 1,
The step of determining the first quantization value,
The first quantization value is determined by performing log quantization on a value corresponding to a quantization level closest to the parameter among the plurality of quantization levels,
The step of determining the second quantization value,
A method of determining the second quantization value by performing log quantization on a value corresponding to a quantization level closest to the error among the plurality of quantization levels.
제 1 항에 있어서,
상기 제 2 양자화 값은,
상기 제 1 양자화 값을 나타내는 비트 수와 동일한 비트 수로 표현되는 방법.
The method of claim 1,
The second quantization value is,
The method expressed by the number of bits equal to the number of bits representing the first quantization value.
제 1 항에 있어서,
상기 임계값은,
상기 뉴럴 네트워크의 인식률 및 상기 파라미터의 양자화에 따른 데이터의 크기 간의 트레이드-오프(trade off) 관계에 기초하여 결정되는 방법.
The method of claim 1,
The threshold is,
The method is determined based on a trade off relationship between the recognition rate of the neural network and the size of data according to quantization of the parameter.
제 1 항에 있어서,
상기 양자화하는 단계는,
상기 제 1 양자화 값 및 상기 제 2 양자화 값 각각에 태그 비트(tag bit)를 추가하는 단계를 더 포함하는 방법.
The method of claim 1,
The quantizing step,
The method further comprising adding a tag bit to each of the first quantization value and the second quantization value.
제 5 항에 있어서,
상기 추가하는 단계는,
상기 제 1 양자화 값에 연속된 상기 제 2 양자화 값이 있음을 나타내는 제 1 태그 비트를 상기 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가하고,
상기 제 2 양자화 값에 연속된 양자화 값이 없음을 나타내는 제 2 태그 비트를 상기 제 2 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가하는 방법.
The method of claim 5,
The step of adding,
A first tag bit indicating that the second quantization value is present in the first quantization value is added before or after the first bit of the bits indicating the first quantization value,
A method of adding a second tag bit indicating that there is no consecutive quantization value to the second quantization value before or after the first bit of the bits indicating the second quantization value.
제 1 항에 있어서,
상기 양자화하는 단계는,
상기 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 및 상기 제 2 양자화 값을 구성하는 비트들 중 마지막 비트의 뒤 중 어느 하나에, 상기 제 1 양자화 값 및 상기 제 2 양자화 값이 연속된 값임을 나타내는 코드 값을 추가하는 단계를 더 포함하는 방법.
The method of claim 1,
The quantizing step,
The first quantization value and the second quantization value are consecutive in any one of a first bit of bits representing the first quantization value and a last bit of the bits constituting the second quantization value. The method further comprising adding a code value indicating that it is a value.
제 1 항에 있어서,
상기 그룹핑된 값을 역양자화하는 단계; 및
상기 그룹핑된 값을 역양자화한 값과 상기 입력 액티베이션 값들간의 컨볼루션(convolution) 연산을 수행하는 단계를 더 포함하는 방법.
The method of claim 1,
Inverse quantizing the grouped values; And
And performing a convolution operation between a value obtained by inverse quantization of the grouped value and the input activation values.
제 8 항에 있어서,
상기 그룹핑된 값을 역 양자화하는 단계는,
상기 제 1 양자화 값을 역양자화한 값인 제 1 역양자화 값 및 상기 제 2 양자화 값을 역양자화한 값인 제 2 역양자화 값 각각을 산출하는 단계; 및
상기 제 1 역양자화 값 및 상기 제 2 역양자화 값을 더하여 상기 그룹핑된 값을 역양자화 값을 획득하는 단계를 더 포함하는 방법.
The method of claim 8,
Inverse quantizing the grouped values,
Calculating each of a first inverse quantization value that is a value obtained by inverse quantization of the first quantization value and a second inverse quantization value that is a value obtained by inverse quantization of the second quantization value; And
And obtaining an inverse quantization value from the grouped value by adding the first inverse quantization value and the second inverse quantization value.
제 1항 내지 제 9항 중 어느 한 항의 방법을 실행하는 명령어들을 포함하는 하나 이상의 프로그램이 기록된 컴퓨터로 읽을 수 있는 기록매체.A computer-readable recording medium on which one or more programs including instructions for executing the method of any one of claims 1 to 9 are recorded. 뉴럴 네트워크를 실시(implement)하는 장치에 있어서,
메모리; 및
뉴럴 네트워크의 레이어에서 처리되는 입력 액티베이션 값들 및 웨이트 값들 중 적어도 하나를 포함하는 파라미터를 양자화하는 프로세서를 포함하고,
상기 프로세서는, 파라미터에 대한 로그 양자화(log quantization)를 수행함으로써 제 1 양자화 값을 결정하고, 상기 제 1 양자화 값에 대한 역양자화(dequantization)에 의해 획득된 제 1 역양자화 값 및 상기 파라미터 간의 오차와 임계값을 비교하고, 상기 비교 결과 상기 오차가 상기 임계값보다 큰 경우, 상기 오차에 대한 로그 양자화를 수행함으로써 제 2 양자화 값을 결정하고, 상기 파라미터를 상기 제 1 양자화 값 및 상기 제 2 양자화 값이 그룹핑된 값으로 양자화하는 장치.
In a device implementing a neural network,
Memory; And
A processor that quantizes a parameter including at least one of input activation values and weight values processed in a layer of a neural network,
The processor determines a first quantization value by performing log quantization on a parameter, and an error between the first inverse quantization value obtained by dequantization of the first quantization value and the parameter And a threshold value, and when the error is greater than the threshold value as a result of the comparison, a second quantization value is determined by performing log quantization on the error, and the parameter is the first quantization value and the second quantization value. A device that quantizes values into grouped values.
제 11 항에 있어서,
상기 프로세서는,
상기 복수의 양자화 레벨들 중에서 상기 파라미터에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 상기 제 1 양자화 값을 결정하고,
상기 복수의 양자화 레벨들 중에서 상기 오차에 가장 근접하는 양자화 레벨에 대응되는 값에 대한 로그 양자화를 수행함으로써 상기 제 2 양자화 값을 결정하는 장치.
The method of claim 11,
The processor,
The first quantization value is determined by performing log quantization on a value corresponding to a quantization level closest to the parameter among the plurality of quantization levels,
An apparatus for determining the second quantization value by performing log quantization on a value corresponding to a quantization level closest to the error among the plurality of quantization levels.
제 11 항에 있어서,
상기 제 2 양자화 값은,
상기 제 1 양자화 값을 나타내는 비트 수와 동일한 비트 수로 표현되는 장치.
The method of claim 11,
The second quantization value is,
The device expressed by the number of bits equal to the number of bits representing the first quantization value.
제 11 항에 있어서,
상기 임계값은,
상기 뉴럴 네트워크의 인식률 및 상기 파라미터의 양자화에 따른 데이터의 크기 간의 트레이드-오프(trade off) 관계에 기초하여 결정되는 장치.
The method of claim 11,
The threshold is,
The apparatus is determined based on a trade-off relationship between the recognition rate of the neural network and the size of data according to quantization of the parameter.
제 11 항에 있어서,
상기 프로세서는,
상기 제 1 양자화 값 및 상기 제 2 양자화 값 각각에 태그 비트(tag bit)를 추가하는 장치.
The method of claim 11,
The processor,
An apparatus for adding a tag bit to each of the first quantization value and the second quantization value.
제 15 항에 있어서,
상기 프로세서는,
상기 제 1 양자화 값에 연속된 상기 제 2 양자화 값이 있음을 나타내는 제 1 태그 비트를 상기 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가하고,
상기 제 2 양자화 값에 연속된 양자화 값이 없음을 나타내는 제 2 태그 비트를 상기 제 2 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 또는 마지막 비트의 뒤에 추가하는 장치.
The method of claim 15,
The processor,
A first tag bit indicating that the second quantization value is present in the first quantization value is added before or after the first bit of the bits indicating the first quantization value,
Apparatus for adding a second tag bit indicating that there is no consecutive quantization value to the second quantization value before or after the first bit of the bits indicating the second quantization value.
제 11 항에 있어서,
상기 프로세서는,
상기 제 1 양자화 값을 나타내는 비트들 중 첫 번째 비트의 앞 및 상기 제 2 양자화 값을 구성하는 비트들 중 마지막 비트의 뒤 중 어느 하나에, 상기 제 1 양자화 값 및 상기 제 2 양자화 값이 연속된 값임을 나타내는 코드 값을 추가하는 장치.
The method of claim 11,
The processor,
The first quantization value and the second quantization value are consecutive in any one of a first bit of bits representing the first quantization value and a last bit of the bits constituting the second quantization value. A device that adds a code value indicating that it is a value.
제 11 항에 있어서,
상기 프로세서는,
상기 그룹핑된 값을 역양자화하고,
상기 그룹핑된 값을 역양자화한 값과 상기 입력 액티베이션 값들간의 컨볼루션(convolution) 연산을 수행하는 장치.
The method of claim 11,
The processor,
Inverse quantization of the grouped values,
An apparatus for performing a convolution operation between a value obtained by inverse quantization of the grouped value and the input activation values.
제 18 항에 있어서,
상기 프로세서는,
상기 제 1 양자화 값을 역양자화한 값인 제 1 역양자화 값 및 상기 제 2 양자화 값을 역양자화한 값인 제 2 역양자화 값 각각을 산출하고,
상기 제 1 역양자화 값 및 상기 제 2 역양자화 값을 더하여 상기 그룹핑된 값을 역양자화 값을 획득하는 장치.
The method of claim 18,
The processor,
Each of a first inverse quantization value that is a value obtained by inverse quantization of the first quantization value and a second inverse quantization value that is a value obtained by inverse quantization of the second quantization value is calculated,
An apparatus for obtaining an inverse quantization value from the grouped value by adding the first inverse quantization value and the second inverse quantization value.
KR1020190104581A 2019-06-03 2019-08-26 Method and apparatus for quantizing parameter in neural network KR20200139071A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US16/890,045 US11531893B2 (en) 2019-06-03 2020-06-02 Method and apparatus with neural network parameter quantization
US17/987,079 US20230085442A1 (en) 2019-06-03 2022-11-15 Method and apparatus with neural network parameter quantization

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US201962856212P 2019-06-03 2019-06-03
US62/856,212 2019-06-03

Publications (1)

Publication Number Publication Date
KR20200139071A true KR20200139071A (en) 2020-12-11

Family

ID=73786335

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020190104581A KR20200139071A (en) 2019-06-03 2019-08-26 Method and apparatus for quantizing parameter in neural network

Country Status (1)

Country Link
KR (1) KR20200139071A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20220125112A (en) * 2021-03-04 2022-09-14 삼성전자주식회사 Neural network operation appratus and method using quantization

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20220125112A (en) * 2021-03-04 2022-09-14 삼성전자주식회사 Neural network operation appratus and method using quantization

Similar Documents

Publication Publication Date Title
KR102601604B1 (en) Method and apparatus for quantizing parameter of neural network
JP7329455B2 (en) Method and apparatus for neural network quantization
KR102526650B1 (en) Method and apparatus for quantizing data in a neural network
US11373087B2 (en) Method and apparatus for generating fixed-point type neural network
JP7304148B2 (en) Method and apparatus for processing convolution operation in neural network
KR20190125141A (en) Method and apparatus for quantizing parameters of neural network
JP7117280B2 (en) Method and apparatus for quantizing parameters of neural network
KR20190052893A (en) Method and apparatus for preprocessing an operation of neural network
US11531893B2 (en) Method and apparatus with neural network parameter quantization
KR20210083935A (en) Method and apparatus for quantizing parameters of neural network
US11513770B2 (en) Neural network method and apparatus with floating point processing
US20210174177A1 (en) Method and device with neural network implementation
US11501166B2 (en) Method and apparatus with neural network operation
JP7329352B2 (en) Method and apparatus for processing parameters in neural networks for classification
CN114358274A (en) Method and apparatus for training neural network for image recognition
KR20210121946A (en) Method and apparatus for neural network quantization
KR20210053791A (en) Method and apparatus for processing data of neural network
KR20200139071A (en) Method and apparatus for quantizing parameter in neural network
KR102581471B1 (en) Method and apparatus for processing parameter in neural network for classification
KR20210076687A (en) Neural processing apparatus and method for processing neural network thereof
JP7189000B2 (en) Information processing equipment, in-vehicle control equipment, vehicle control system
KR20230123309A (en) Pruning method and apparatus
CN114254746A (en) Method and apparatus for performing neural networks