KR20220114890A - Method for computing neural network using ruduction-repetition block and apparatus using the same - Google Patents

Method for computing neural network using ruduction-repetition block and apparatus using the same Download PDF

Info

Publication number
KR20220114890A
KR20220114890A KR1020210018472A KR20210018472A KR20220114890A KR 20220114890 A KR20220114890 A KR 20220114890A KR 1020210018472 A KR1020210018472 A KR 1020210018472A KR 20210018472 A KR20210018472 A KR 20210018472A KR 20220114890 A KR20220114890 A KR 20220114890A
Authority
KR
South Korea
Prior art keywords
neural network
quantization
applying
convolution
learning
Prior art date
Application number
KR1020210018472A
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 KR1020210018472A priority Critical patent/KR20220114890A/en
Priority to PCT/KR2021/016682 priority patent/WO2022173095A1/en
Publication of KR20220114890A publication Critical patent/KR20220114890A/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/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Neurology (AREA)
  • Image Analysis (AREA)

Abstract

As a method for operating a neural network of a neural network operation device, the present invention comprises: a step of separating the input data in a depth direction to shift according to a pre-operated inclination; and a step of applying quantization to a point-wise convolution of the shifted data. Therefore, the present invention is capable of having an effect of improving a storage size and learning time of the neural network.

Description

뉴럴 네트워크 연산 방법 및 이를 위한 장치{METHOD FOR COMPUTING NEURAL NETWORK USING RUDUCTION-REPETITION BLOCK AND APPARATUS USING THE SAME} Neural network computation method and apparatus therefor

본 발명은 뉴럴 네트워크 연산 방법 및 이를 위한 장치에 관한 것이고, 보다 구체적으로, 컨볼로션 뉴럴 네트워크 연산을 대체하는 시프트 연산과 양자화 모델을 결합한 경량화된 뉴럴 네트워크 연산 방법 및 이를 위한 장치에 관한 것이다. The present invention relates to a neural network computation method and an apparatus therefor, and more particularly, to a lightweight neural network computation method by combining a shift operation and a quantization model that replaces a convolutional neural network operation, and an apparatus therefor.

딥러닝(deep learning) 기술의 핵심 계산 모형인 컨벌루션 신경망(CNN : Convolutional Neural Network, 이하에서 "CNN"이라고 지칭함)은, 각각의 뉴런이 인간의 시각 신경계에서 중복 영역의 응답 특성과 유사한 특성을 갖도록 다중 계층으로 배치된 인공신경망의 한 종류이다.Convolutional Neural Network (CNN, hereinafter referred to as "CNN"), a core computational model of deep learning technology, is designed so that each neuron has characteristics similar to the response characteristics of overlapping regions in the human visual nervous system. It is a type of artificial neural network arranged in multiple layers.

CNN은 계층의 수가 많아질수록 복잡한 패턴의 영상 및 음성을 높은 인식률로 인식할 수 있다는 장점이 있다. 그에 따라, 오랫동안 정체 상태에 머물러 있던 영상 및 음성 인식률이 최근 들어 CNN 기술에 의해 극적으로 높아지고, ImageNet과 같은 각종 영상인식 벤치마킹시험에서 CNN 시스템들이 최고기록을 경신하고 있다. 그 결과, CNN은 영상인식, 음성인식, 언어번역 등 다양한 머신러닝(machine learning) 분야에서 각광받고 있다.As the number of layers increases, CNN has the advantage of being able to recognize images and voices of complex patterns with a high recognition rate. Accordingly, the image and voice recognition rates, which have been stagnant for a long time, have recently increased dramatically by CNN technology, and CNN systems are breaking new records in various image recognition benchmarking tests such as ImageNet. As a result, CNN is in the spotlight in various machine learning fields such as image recognition, voice recognition, and language translation.

CNN 시스템은 일반적으로 컨벌루션 필터(convolutional filters)("가중치 커널(weight kernels)" 또는 "커널(kernels)"이라고 함)의 다중 레이어들을 포함할 수 있다. 각각의 컨벌루션 레이어는 입력으로서 피쳐 맵(feature map)을 수신할 수 있으며, 피쳐 맵은 컨벌브된 출력(convolved ouput)을 생성하기 위해 커널과 컨벌브될 수 있다. 각 레이어에서 처리가 요구되는 많은 수의 피쳐 맵들, 큰 커널 사이즈들 및 딥 뉴럴 네트워크(deepneural networks)에서 증가하는 수의 레이어들로 인해, CNN 시스템을 트레이닝(training)하고 실행(running)하는 것은 일반적으로 데이터셋과 모델이 너무 커서 시간이 오래 걸리고 다루기 힘들다. 또한, 복잡성은 입력 크기가 커짐(예를 들어, FHD(Full High Definition) 이미지)에 따라 증가할 수 있다. 여기서, 입력 피쳐 맵(input feature maps) 및 모든 중간 피쳐 맵(intermediate feature maps)이 더 넓은 폭 및 높이를 갖도록 변화하기 때문에 입력 크기가 커지게 된다.A CNN system may generally include multiple layers of convolutional filters (referred to as “weight kernels” or “kernels”). Each convolutional layer may receive a feature map as input, which may be convolved with a kernel to produce a convolved output. Due to the large number of feature maps that require processing at each layer, large kernel sizes and the increasing number of layers in deep neural networks, it is common to train and run CNN systems. As the dataset and model are too large, it takes a long time and is difficult to handle. In addition, complexity may increase as an input size increases (eg, a Full High Definition (FHD) image). Here, the input size is increased because the input feature maps and all intermediate feature maps are changed to have a wider width and height.

보행자 감지(pedestrian detection)와 같은 많은 애플리케이션은 신속한 실시간 치리가 필요하다. 현재 하드웨어 아키텍쳐(Hardware Architecture) 및 그래픽 처리 장치(GPU; Graphical Processing Units)는 프로세스 속도를 높이기 위해 여러 프로세싱 장치에서 병렬 처리를 목표로 한다. 그러나, 모바일 디바이스와 같은 전력이 제한된 전자 장치에 딥 컨벌루션 뉴럴 네트워크(deep convolution neural networks) 시스템을 구현하는 최근의 추세로 인해, 전력 소비를 줄이고 처리 시간을 단축시키기 위한 계산상의 부담을 줄이는 것이 바람직하다.Many applications, such as pedestrian detection, require fast, real-time treatment. Current hardware architectures and graphic processing units (GPUs) aim for parallel processing in multiple processing units to speed up processes. However, with the recent trend of implementing deep convolution neural networks systems in power-constrained electronic devices such as mobile devices, it is desirable to reduce the computational burden to reduce power consumption and shorten processing time. .

[선행기술문헌][Prior art literature]

[비특허문헌1] BiChen Wu et. al., "Shift: A Zero FLOP, Zero Parameter Alternative to Spatial Convolution," CVPR 2017.[Non-Patent Document 1] BiChen Wu et. al., “Shift: A Zero FLOP, Zero Parameter Alternative to Spatial Convolution,” CVPR 2017.

[비특허문헌2] Yunho Jeon, Junmo Kim, "Constructing Fast Network through Deconstruction of Convolution," NIPS 2019[Non-Patent Document 2] Yunho Jeon, Junmo Kim, "Constructing Fast Network through Deconstruction of Convolution," NIPS 2019

[비특허문헌3] Weijie Chen et. al., "All you need is a Few Shifts: Designing Efficient Convolutional Neural Networks for Image Classification," CVPR 2019[Non-Patent Document 3] Weijie Chen et. al., "All you need is a Few Shifts: Designing Efficient Convolutional Neural Networks for Image Classification," CVPR 2019

본 발명은 계산 복잡성을 감소시키는 뉴럴 네트워크 연산 방법 및 이를 위한 장치를 제공하고자 한다.An object of the present invention is to provide a neural network computation method for reducing computational complexity and an apparatus therefor.

본 발명의 기술적 과제들은 이상에서 언급한 기술적 과제로 제한되지 않으며, 언급되지 않은 또 다른 기술적 과제들은 아래의 기재로부터 당업자에게 명확하게 이해될 수 있을 것이다.The technical problems of the present invention are not limited to the technical problems mentioned above, and other technical problems not mentioned will be clearly understood by those skilled in the art from the following description.

일 실시예에서, 상기 뉴럴 네트워크 연산 장치의 뉴럴 네트워크 연산 방법으로서, 입력 데이터를 깊이 방향으로 분리하여 미리 연산된 기울기에 따라 시프트하는 단계; 및 시프트된 데이터의 지점 화 컨벌루션(point-wise convolution)에 양자화를 적용하는 단계를 포함하는 것을 특징으로 한다. In one embodiment, there is provided a neural network computation method of the neural network computation apparatus, the method comprising: dividing input data in a depth direction and shifting it according to a pre-calculated gradient; and applying quantization to a point-wise convolution of the shifted data.

일 실시예에서, 상기 뉴럴 네트워크 연산 방법은, 상기 양자화를 적용하는 단계는 상기 시프트된 데이터를 쌍곡 탄젠트(hyperbolic tangent)에 기초하여 전처리하고, 양자화된 가중치와 이에 대한 기울기를 연산하는 것을 특징으로 한다. In one embodiment, in the neural network calculation method, the step of applying the quantization is characterized in that the shifted data is preprocessed based on a hyperbolic tangent, and a quantized weight and a gradient thereof are calculated. .

일 실시예에서, 상기 양자화를 적용하는 단계는 소수의 채널 사이에서 동일한 블록을 연결하는 역잔여 블록을 채택하는 것을 특징으로 한다. In one embodiment, the step of applying the quantization is characterized by employing an inverse residual block connecting the same block among the few channels.

일 실시예에서, 상기 양자화를 적용하는 단계는 활성 함수 양자화비트를 4비트로 제한하고, 가중치 양자화를 1비트로 제한하는 것을 특징으로 한다. In one embodiment, the step of applying the quantization is characterized in that the active function quantization bits are limited to 4 bits and the weight quantization is limited to 1 bit.

일 실시예에서, 상기 양자화를 적용하는 단계 이후에는 각 피쳐 별 평균(mean)과 분산(variance)에 기초하여 배치 정규화(batch normalization)를 수행하는 단계를 더 포함하는 것을 특징으로 한다. In an embodiment, after the step of applying the quantization, the method may further include performing batch normalization based on a mean and variance for each feature.

일 실시예에서, 상기 미리 연산된 기울기는 뉴럴 네트워크의 손실함수를 최적화하는 방향으로 연산되는 것을 특징으로 한다. In an embodiment, the pre-computed gradient is calculated in a direction to optimize the loss function of the neural network.

일 실시예에서, 양자화된 데이터를 정규화(normalization)하고, 평균 통합(average Pooling) 하여, 활성함수를 적용한 후, 선형계층에서 완전연결하는 단계를 더 포함하는 것을 특징으로 한다. In an embodiment, the method further comprises: normalizing the quantized data, performing average pooling, applying an activation function, and then completely connecting the quantized data in a linear layer.

일 실시예에서, 상기 손실함수는 웜업(warm-up) 길이와 스텝 사이즈(step-size)를 하이퍼 파라미터로 하는 코사인 학습율과 Nestrov 최적화 알고리즘을 결합하여 최적화하는 것을 특징으로 한다. In an embodiment, the loss function is optimized by combining a cosine learning rate using a warm-up length and a step-size as hyper parameters and a Nestrov optimization algorithm.

일 실시예에서, 첫번째 학습시에는 가중치에만 양자화 비트를 적용하여 전체 에포치에 대해 학습하고, 두번째 학습시에는 가중치와 활성함수를 모두 양자화하여 학습을 수행하는 것을 특징으로 한다.In one embodiment, in the first learning, the entire epoch is learned by applying the quantization bit only to the weight, and in the second learning, the learning is performed by quantizing both the weight and the activation function.

본 발명은 컴퓨터 프로그램이 프로세서에 의해 실행될 때, 상술된 방법이 수행되는 컴퓨터 프로그램을 저장한 컴퓨터-판독가능 저장 매체를 제공한다.The present invention provides a computer-readable storage medium storing a computer program in which the above-described method is performed when the computer program is executed by a processor.

본 발명의 일 실시예에 따르면, 이러한 시프트 연산을 통해 경량화한 네트워크의 가중치 및 활성함수를 양자화 방법을 통해 추가적으로 경량화 하는 연산을 동시에 진행하여 뉴럴 네트워크의 저장 크기 및 학습 시간 개선하는 효과가 있다. According to an embodiment of the present invention, there is an effect of improving the storage size and learning time of the neural network by concurrently performing an operation for additionally reducing the weight and activation function of the network, which is lightweight through the shift operation, through the quantization method.

도 1은 종래의 컨벌루션 뉴럴 네트워크에 적용되는 컨벌루션 동작을 설명하기 위한 도면이다.
도 2는 본 발명의 일 실시예에 따른 시프트 연산을 설명하기 위한 도면이다.
도 3은 본 발명의 일 실시예에 따른 시프트 연산 블록 구조를 설명하기 위한 도면이다.
도 4는 잔여 블록과 역잔여 블록을 설명하기 위한 도면이다.
도 5는 본 발명의 일 실시예에 따른 역동일 연결 잔여 블록을 설명하기 위한 도면이다.
도 6은 본 발명의 일 실시예에 따른 계층별 학습 파라미터의 비율을 다른 모델과 비교 설명하는 도면이다.
도 7은 본 발명의 다른 실시예에 따른 뉴럴 네트워크 연산 방법을 설명하기 위한 도면이다.
1 is a diagram for explaining a convolution operation applied to a conventional convolutional neural network.
2 is a diagram for explaining a shift operation according to an embodiment of the present invention.
3 is a diagram for explaining the structure of a shift operation block according to an embodiment of the present invention.
4 is a diagram for explaining a residual block and an inverse residual block.
5 is a diagram for explaining a residual block of inversely identical concatenation according to an embodiment of the present invention.
6 is a diagram illustrating a comparison of a ratio of learning parameters for each layer with other models according to an embodiment of the present invention.
7 is a diagram for explaining a neural network calculation method according to another embodiment of the present invention.

본 발명은 다양한 변경을 가할 수 있고 여러 가지 실시예를 가질 수 있는 바, 특정 실시예들을 도면에 예시하고 상세한 설명에 상세하게 설명하고자 한다. 그러나, 이는 본 발명을 특정한 실시 형태에 대해 한정하려는 것이 아니며, 본 발명의 사상 및 기술 범위에 포함되는 모든 변경, 균등물 내지 대체물을 포함하는 것으로 이해되어야 한다. 각 도면을 설명하면서 유사한 참조부호를 유사한 구성요소에 대해 사용하였다.Since the present invention can have various changes and can have various embodiments, specific embodiments are illustrated in the drawings and described in detail in the detailed description. However, this is not intended to limit the present invention to specific embodiments, and should be understood to include all modifications, equivalents and substitutes included in the spirit and scope of the present invention. In describing each figure, like reference numerals have been used for like elements.

제1, 제2, A, B 등의 용어는 다양한 구성요소들을 설명하는데 사용될 수 있지만, 상기 구성요소들은 상기 용어들에 의해 한정되어서는 안 된다. 상기 용어들은 하나의 구성요소를 다른 구성요소로부터 구별하는 목적으로만 사용된다. 예를 들어, 본 발명의 권리 범위를 벗어나지 않으면서 제1 구성요소는 제2 구성요소로 명명될 수 있고, 유사하게 제2 구성요소도 제1 구성요소로 명명될 수 있다. 및/또는 이라는 용어는 복수의 관련된 기재된 항목들의 조합 또는 복수의 관련된 기재된 항목들 중의 어느 항목을 포함한다.Terms such as first, second, A, and B may be used to describe various elements, but the elements should not be limited by the terms. The above terms are used only for the purpose of distinguishing one component from another. For example, without departing from the scope of the present invention, a first component may be referred to as a second component, and similarly, a second component may also be referred to as a first component. and/or includes a combination of a plurality of related listed items or any of a plurality of related listed items.

어떤 구성요소가 다른 구성요소에 "연결되어" 있다거나 "접속되어" 있다고 언급된 때에는, 그 다른 구성요소에 직접적으로 연결되어 있거나 또는 접속되어 있을 수도 있지만, 중간에 다른 구성요소가 존재할 수도 있다고 이해되어야 할 것이다. 반면에, 어떤 구성요소가 다른 구성요소에 "직접 연결되어" 있다거나 "직접 접속되어" 있다고 언급된 때에는, 중간에 다른 구성요소가 존재하지 않는 것으로 이해되어야 할 것이다.When a component is referred to as being “connected” or “connected” to another component, it may be directly connected or connected to the other component, but it is understood that other components may exist in between. it should be On the other hand, when it is said that a certain element is "directly connected" or "directly connected" to another element, it should be understood that the other element does not exist in the middle.

본 출원에서 사용한 용어는 단지 특정한 실시예를 설명하기 위해 사용된 것으로, 본 발명을 한정하려는 의도가 아니다. 단수의 표현은 문맥상 명백하게 다르게 뜻하지 않는 한, 복수의 표현을 포함한다. 본 출원에서, "포함하다" 또는 "가지다" 등의 용어는 명세서상에 기재된 특징, 숫자, 단계, 동작, 구성요소, 부품 또는 이들을 조합한 것이 존재함을 지정하려는 것이지, 하나 또는 그 이상의 다른 특징들이나 숫자, 단계, 동작, 구성요소, 부품 또는 이들을 조합한 것들의 존재 또는 부가 가능성을 미리 배제하지 않는 것으로 이해되어야 한다.The terms used in the present application are only used to describe specific embodiments, and are not intended to limit the present invention. The singular expression includes the plural expression unless the context clearly dictates otherwise. In the present application, terms such as “comprise” or “have” are intended to designate that a feature, number, step, operation, component, part, or combination thereof described in the specification exists, but one or more other features It is to be understood that this does not preclude the possibility of the presence or addition of numbers, steps, operations, components, parts, or combinations thereof.

다르게 정의되지 않는 한, 기술적이거나 과학적인 용어를 포함해서 여기서 사용되는 모든 용어들은 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자에 의해 일반적으로 이해되는 것과 동일한 의미를 가지고 있다. 일반적으로 사용되는 사전에 정의되어 있는 것과 같은 용어들은 관련 기술의 문맥 상 가지는 의미와 일치하는 의미를 가지는 것으로 해석되어야 하며, 본 출원에서 명백하게 정의하지 않는 한, 이상적이거나 과도하게 형식적인 의미로 해석되지 않는다.Unless defined otherwise, all terms used herein, including technical or scientific terms, have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. Terms such as those defined in a commonly used dictionary should be interpreted as having a meaning consistent with the meaning in the context of the related art, and should not be interpreted in an ideal or excessively formal meaning unless explicitly defined in the present application. does not

발명의 설명에 앞서, 컨벌루션 뉴럴 네트워크(Convolution Neural Networks, 이하 'CNN') 시스템을 트레이닝(training)하고 러닝(running)하는 것은 일반적으로 데이터 셋과 모델이 너무 커서 시간이 오래 걸리고 다루기 힘들다. Prior to the description of the invention, training and running a convolutional neural network (hereinafter referred to as 'CNN') system is generally time-consuming and difficult to handle because the data set and model are too large.

도 1은 종래의 컨벌루션 뉴럴 네트워크에 적용되는 컨벌루션 동작을 설명하기 위한 도면이다. 1 is a diagram for explaining a convolution operation applied to a conventional convolutional neural network.

도 1을 참조하여, 전형적인 컴퓨테셔널 코스트(computational cost)를 설명하기 위한 피쳐 맵(101, feature map)과 커널(102, kernel)의 예시적인 컨벌루션 동작(convolution operation)을 설명한다. 피쳐 맵(101)은 C 개의 입력 채널, W 및 H의 폭을 갖는 각각의 채널을 갖는 3차원 매트릭스 구조로 표현될 수 있다. 여기서, C, W 및 H는 양의 정수일 수 있다. 따라서, 피쳐 맵(101)은 W x H x C의 차원을 가질 수 있다. 도 1의 일 실시예에서 피쳐 맵(101)은 8 x 8 x 3의 구조를 예시하였다. Referring to FIG. 1 , an exemplary convolution operation of a feature map 101 and a kernel 102 for describing a typical computational cost will be described. The feature map 101 may be represented as a three-dimensional matrix structure having C input channels, each channel having a width of W and H. Here, C, W and H may be positive integers. Accordingly, the feature map 101 may have dimensions of W x H x C. In the embodiment of FIG. 1 , the feature map 101 exemplifies a structure of 8×8×3.

커널(102)은 M x R x S의 차원을 갖는 3차원 매트릭스 구조로 표현될 수도 있다. 여기서, M, R, S 또한 양의 정수일 수 있다. 피쳐 맵(101)을 커널(102)과 컨벌루션(convolution)함으로써 W x H x M의 차원을 갖는 컨벌브된 출력(103)을 생성할 수 있다. 예를 들어, 출력은 M개의 채널들을 가질 수 있다.The kernel 102 may be represented as a three-dimensional matrix structure having dimensions of M x R x S. Here, M, R, and S may also be positive integers. By convolving the feature map 101 with the kernel 102 , a convolved output 103 having dimensions of W x H x M can be generated. For example, the output may have M channels.

도 1의 일 실시예에서 커널(102)은 8 x 8 x 3의 구조를 예시하였다. In the embodiment of FIG. 1 , the kernel 102 exemplifies a structure of 8×8×3.

컨벌루션은 MAC(Multiply accumulate) 유닛의 어레이(array)를 반복적으로 사용함으로써 수행될 수 있다. MAC은 두 개의 수신된 값의 곱을 계산하고, 그 결과를 레지스터에 누적하는 정상 시퀀셜 회로(normal sequential circuit)일 수 있다. 입력 피쳐 맵이 더 넓은 폭 및 높이를 갖도록 변화하면 컨벌루션도 이미지 크기에 따라 증가한다. Convolution can be performed by repeatedly using an array of MAC (Multiply accumulate) units. The MAC may be a normal sequential circuit that calculates the product of two received values and accumulates the result in a register. If the input feature map is changed to have a wider width and height, the convolution also increases with the image size.

도 2는 본 발명의 일 실시예에 따른 시프트 연산을 설명하기 위한 도면이고, 도 3은 본 발명의 일 실시예에 따른 시프트 연산 블록 구조를 설명하기 위한 도면이다. FIG. 2 is a diagram for explaining a shift operation according to an embodiment of the present invention, and FIG. 3 is a diagram for explaining a structure of a shift operation block according to an embodiment of the present invention.

도 2의 (a) 및 도 3을 참조하면, 공간 시프트 컨벌루션은 분리가능한 채널을 각각 미리 연산된 기울기로 시프트한다. 이로써, 공간 시프트 컨벌루션은 특정 필터를 기반으로 한 컨벌루션 연산의 결과 특성 맵이 특정 방향으로 메모리 시프팅한 것과 동일한 결과를 가져온다. 이때의 특정 필터의 일 예는 3 x3 커널의 경우, 하나만 1이고 나머지는 0으로 이루어진 필터일 수 있다. 따라서, 공간 시프트 컨벌루션은 덧셈 또는 곱셈 연산없이 메모리 시프트 연산으로 대체될 수 있다. 그후, 공간 분리가능한 채널(point-wise) 컨벌루션에서의 공간 컨벌루션 연산은 시프트 컨벌루션으로 대체된다. 시프트 연산을 적용할 때, 동일 기울기를 갖는 그룹을 묶어 그룹별 채널 시프트를 취할 수 있다. 이를 그룹 시프트라하며, 그룹 시프트는 수용 영역을 줄일 수 있다. 이 시프트 컨벌루션은 각 채널 그룹의 시프트 방향을 계산하는 그룹 시프트에서 손실 연산에 각 채널에 대한 시프트 연산을 추가하여 기울기 연산을 수행하는 활성 시프트로 진화한다. Referring to FIGS. 2A and 3 , the spatial shift convolution shifts a separable channel by a pre-computed slope, respectively. As a result, spatial shift convolution yields the same result as memory shifting of a result characteristic map of a convolution operation based on a specific filter in a specific direction. An example of a specific filter at this time may be a filter in which only one is 1 and the others are 0 in the case of a 3x3 kernel. Thus, the spatial shift convolution can be replaced with a memory shift operation without addition or multiplication operations. Then, the spatial convolution operation in the spatially separable channel (point-wise) convolution is replaced by the shift convolution. When the shift operation is applied, a channel shift for each group may be obtained by grouping groups having the same slope. This is called a group shift, and the group shift can reduce the accommodation area. This shift convolution evolves from a group shift that calculates the shift direction of each channel group to an active shift that performs a gradient operation by adding the shift operation for each channel to the loss operation.

활성 시프트는 시프트 컨벌루션의 정확도를 향상시킨다. 활성 시프트에서 각 레이어 블록은 최적화된 시프트값(α, β)(즉, 각 채널에 대한 수평 시프트 양, 수직 시프트 양)에 대해 역 전파(back-propagation)를 통해 최적의 기울기 값을 찾는다. 메모리 시프트 연산은 정수가 아닌 실수값에도 대응이되도록 보간 방법 예를 들어, 이중 선형(bi-linear) 보간 방법을 사용하여 자동 최적화 시프트 연산을 수행한다. 이중 선형(bi-linear) 보간은 알려진 지점의 값 사이(중간)에 위치하는 값을 추정하는 보간법을 2D로 확장한 보간법이다. 원래 사각형의 네점 ABCD를 각각 A', B', C', D'로 변환시키는 선형변환 T를 구한 후, 선형변환 T를 이용하여 사각형 ABCD 내부의 한점 p를 변환시킨 p'를 구할 수 있다. Active shift improves the accuracy of shift convolution. In the active shift, each layer block finds an optimal gradient value through back-propagation with respect to the optimized shift values (α, β) (ie, the horizontal shift amount and the vertical shift amount for each channel). The memory shift operation performs an automatic optimization shift operation using an interpolation method, for example, a bi-linear interpolation method, so that it corresponds to a real value other than an integer. Bi-linear interpolation is an interpolation method that is extended to 2D by estimating a value located between (middle) values of known points. After obtaining a linear transformation T that transforms the four points ABCD of the original rectangle into A', B', C', and D', respectively, the linear transformation T can be used to obtain p' obtained by transforming one point p inside the rectangle ABCD.

이 때의 기울기 값은 뉴럴 네트워크의 손실 함수를 최적화하는 방향으로 연산하여 구한다. 이를 통해 최적의 시프트 값을 계산하는 기울기 descent 방법을 사용할 수 있다. At this time, the gradient value is obtained by calculating in the direction of optimizing the loss function of the neural network. Through this, a gradient descent method that calculates an optimal shift value can be used.

활성 시프트는 커널 사이즈에 독립적인 장점이 있다. 그룹 시프트는 커널 사이즈가 변하면 시프트하는 그룹의 수를 최적화하기 위해 시프트 연산을 변화시키는 반면 활성 시프트는 훈련과 역전파를 통해 최적화된 시프트 연산을 찾는다. 활성 시프트는 채널별 시프트를 수행함으로써 확장된 컨벌루션(dilated convolution)과 같이 수용 영역을 늘려 연산 성능을 향상시킨다. Active shift has the advantage of being independent of kernel size. Group shift changes the shift operation to optimize the number of shifting groups when the kernel size changes, whereas active shift finds an optimized shift operation through training and backpropagation. Active shift improves computational performance by increasing the accommodating area like dilated convolution by performing a shift for each channel.

일 실시예에서, 시프트 연산의 효율성을 향상시키기 위해 희소 시프트(sparse shift)는 코어 시프트만 남기면서 연산을 줄이는 미분 가능한 양자화 학습 방법(quantization-aware learning method)인다. 보다 구체적으로 희소 시프트는 정수가 이중 선형(bi-linear)보간 연산을 제거한다. 일 실시예에서, 심도별(depth-wise) 분리 가능한 지점 화 컨벌루션을 시프트 컨벌루션 프로세스로 대체하여 컨벌루션을 경량화한다. In one embodiment, to improve the efficiency of the shift operation, sparse shift is a differentiable quantization-aware learning method that reduces the operation while leaving only the core shift. More specifically, the sparse shift eliminates integer bi-linear interpolation operations. In one embodiment, the convolution is lightweight by replacing the depth-wise separable branched convolution with a shift convolution process.

일 실시예에 따른 뉴럴 네트워크 연산 방법에서는 다중비트 구조를 적용하고 지점 화 컨벌루션에 시프트 컨벌루션과 양자화를 적용하여 비트 수를 줄인다. In the neural network calculation method according to an embodiment, the number of bits is reduced by applying a multi-bit structure and applying shift convolution and quantization to branched convolution.

다중비트 구조를 적용함으로써, 채널 방향으로 더하기를 수행하는 1 x 1 컨벌루션 연산에서 비트수를 줄일 수 있다. 입력 데이터가 3차원 이미지 데이터일 때, (높이, 너비, 채널)로 구성될 수 있다. 여기서 채널은 예를 들어, 이미지가 가진 색상을 표현하기 위해 필요한 적(Red), 녹(green), 청(blue)을 뜻할 수 있다. 컬러 사진은 3개의 채널을 가지며 참고로 흑백 사진은 채널이 1 이므로 2차원의 데이터가 된다. By applying the multi-bit structure, it is possible to reduce the number of bits in a 1 x 1 convolution operation that performs addition in the channel direction. When the input data is 3D image data, it may be composed of (height, width, channel). Here, the channel may mean, for example, red, green, and blue necessary to express the color of the image. A color photo has three channels, and for reference, a black-and-white photo has a channel of 1, so it becomes two-dimensional data.

도 2의 (b) 및 도 3을 참조하면, 시프된 데이터를 지점 화 컨벌루션(point-wise convolution) 양자화한다. 정확도와 모델 사이즈를 고려하여 활성 함수 양자화비트를 4비트로 제한하고, 가중치 양자화를 1비트로 제한할 수 있다. 여기서, 활성함수는 신경망회로에서, 한 노드에 대해 입력값을 다음 노드에 보낼지 말지에 대해 결정하는 함수이다. 2B and 3 , the shifted data is quantized by point-wise convolution. In consideration of accuracy and model size, active function quantization bits may be limited to 4 bits, and weight quantization may be limited to 1 bit. Here, the activation function is a function that determines whether to send an input value to the next node for one node in the neural network circuit.

도 4는 잔여 블록과 역잔여 블록을 설명하기 위한 도면이다. 4 is a diagram for explaining a residual block and an inverse residual block.

도 4의 (a)와 같이 종래의 잔여 블록들은 채널수가 많은 레이어들을 동일 연결한다. 반면, 도 4의 (b)와 같이 역 잔여 블록은 채널수가 적은 레이어 동일 연결한다. As shown in (a) of FIG. 4 , the conventional residual blocks connect layers having a large number of channels in the same manner. On the other hand, as shown in (b) of FIG. 4 , the inverse residual block is connected to a layer having a small number of channels.

도 5는 본 발명의 일 실시예에 따른 역동일 연결 잔여 블록을 설명하기 위한 도면이다. 5 is a diagram for explaining a residual block of inversely identical concatenation according to an embodiment of the present invention.

도 5를 참조하면, 역동일 연결 잔여 블록은 네 계층으로 구성하는데 입력 데이터에 대해 그 모양이 입구와 출력 부분이 채널수를 줄이는 병목 블록 형태이다. 처음 계층은 채널수를 줄인 1x1 지점 화 컨벌루션 계층을 통과한다. 이후 채널수를 늘인 두 계층의 컨벌루션 계층을 통과 후 다시 이를 초기 계층 채널을 결합하는 1x1 지점 화 컨벌루션 계층에서 동일 연결로 구성한다. SSPQ도 이와 유사한 역동일 연결 잔여 병목 블록으로 구성되어 있으되, 두 계층의 3x3 컨벌루션 연결이 한 계층의 이동 계층(Shift Layer)로 대체된 형태이다. 도 4에 도시된 바와 같이, 1x1 컨벌루션은 채널별 덧셈을 수행하는 연산이다. 이는 MobileNetV1에 소개된 깊이 방향으로 분리한 컨벌루션(Depth-wise Separable Convolution)중 채널 별 공간 (Spatial) 필터와 컨벌루션을 수행 후 연산된 채널들을 합산하는 연산을 지칭한다. 공간 방향으로 볼 때 하나의 지점으로 보이는 관계로 지점 방향 컨벌루션이라 칭하기도 한다. 계층 50을 넘어서는 병목블록에서 채널수 확장을 위해서는 잔여 연결(identity connection)시 채널의 개수를 보통 4배로 확장한다.Referring to FIG. 5 , the inversely identically connected residual block is composed of four layers, and for input data, the shape is a bottleneck block type in which the inlet and output portions reduce the number of channels. The first layer is passed through a 1x1 branched convolutional layer with reduced number of channels. After that, it passes through the convolutional layers of the two layers with the number of channels increased, and configures them as the same connection in the 1x1 branched convolutional layer that combines the initial layer channels again. SSPQ also consists of a similar inverse identically connected residual bottleneck block, but the 3x3 convolutional connection of two layers is replaced by a shift layer of one layer. As shown in FIG. 4 , 1x1 convolution is an operation for performing addition for each channel. This refers to an operation of summing the calculated channels after performing convolution with a spatial filter for each channel among the depth-wise separable convolution introduced in MobileNetV1. Since it looks like a single point when viewed in the spatial direction, it is also called point-direction convolution. In order to expand the number of channels in a bottleneck block beyond layer 50, the number of channels is usually quadrupled during the remaining connection (identity connection).

도 1에서 설명한 바와 같이, 일반적으로 컨벌루션은 C Х W Х H 크기의 입력텐서 I에 C Х K Х K 사이즈의 D 컨벌루션 필터 {F 1, F 2, . . . , F D}를 적용하여 D Х W Х H 크기의 출력텐서 O로 변환하는 과정이다. As described in FIG. 1, in general, convolution is performed on an input tensor I of size C Х W Х H with a D convolution filter of size C Х K Х K {F 1 , F 2 , . . . , F D } is applied to transform the output tensor O of size D Х W Х H.

이를 수학식 1과 같이 나타낼 수 있다.This can be expressed as Equation (1).

[수학식 1][Equation 1]

Figure pat00001
Figure pat00001

활성 시프트 컨벌루션은 수학식 2를 참조하여 C × K × K 크기의 D 필터를 c ×2크기의 시프트 연산으로 대체하고 K2 /2 배 줄임으로써 연산량을 감소시킨다. Active shift convolution reduces the amount of computation by replacing the C × K × K D filter with a c × 2 shift operation and reducing K 2 /2 times with reference to Equation (2).

[수학식 2][Equation 2]

Figure pat00002
Figure pat00002

공간 컨벌루션은 수학식 1과 2에 표시된 곱셈 연산이고 그래픽 처리장치를 사용하는 D병렬 연산이다. Spatial convolution is a multiplication operation shown in Equations 1 and 2 and is a D-parallel operation using a graphic processing unit.

수학식 1와 2의 D덧셈은 지점 화 컨벌루션이기 때문에, 일 실시예에서는 이 컨벌루션 과정에 양자화 연산을 적용한다. 이를 통해 작은 비트 연산으로 계산 이득을 얻을 수 있다. Since the addition of D in Equations 1 and 2 is a branched convolution, in an embodiment, a quantization operation is applied to this convolution process. This allows computational gains to be achieved with small bitwise operations.

지점 화 연산은 정밀도 비트 수를 줄여 양자화를 지원하는데 사용된다. 특히 다중 비트 자원과 바이너리 비트를 할당할 수 있는 최적의 DoReFa-Net 모델을 적용한다. The branching operation is used to support quantization by reducing the number of bits of precision. In particular, the optimal DoReFa-Net model that can allocate multi-bit resources and binary bits is applied.

도 3과 같이 역 잔여 블록의 지점 화 컨벌루션 결과를 활성 시프트 레이어 입력에 전달할 때, 클립 함수는 하기의 DoReFa-Net 수학식3을 통해 대체된다. As shown in FIG. 3 , when the branching convolution result of the inverse residual block is transmitted to the active shift layer input, the clip function is replaced through the following DoReFa-Net Equation (3).

연산 비트 크기에 따른 양자화값은 활성 시프트 레이어의 입력값으로 계산된다. A quantization value according to the operation bit size is calculated as an input value of the active shift layer.

DoReFa-Net 의 양자화는 두 단계로 구성된다. 먼저, 입력 데이터 ir∈[0, 1] 에 대하여 수학식 3에서와 같이, 쌍곡 탄젠트(hyperbolic tangent)에 기초하여 전처리 한다. 다음 전처리된 입력

Figure pat00003
에 대해 양자화된 가중치
Figure pat00004
를 수학식 4와 같이 계산한다. Quantization of DoReFa-Net consists of two steps. First, as in Equation 3, the input data i r ∈[0, 1] is preprocessed based on the hyperbolic tangent. Next preprocessed input
Figure pat00003
quantized weights for
Figure pat00004
is calculated as in Equation 4.

[수학식 3][Equation 3]

Figure pat00005
Figure pat00005

[수학식 4][Equation 4]

Figure pat00006
Figure pat00006

수학식 3에서, ir은 가중치 행렬이거나 Relu(WX + b)와 같은 활성함수를 통해 획득한 값이다. back-propagation경우, 양자화된 가중치에 대한 기울기는 수학식 5와 6에 의해 계산된다. In Equation 3, i r is a weight matrix or a value obtained through an activation function such as Relu(WX + b). In the case of back-propagation, the gradient for the quantized weight is calculated by Equations 5 and 6.

[수학식 5][Equation 5]

Figure pat00007
Figure pat00007

[수학식 6][Equation 6]

Figure pat00008
Figure pat00008

도 6은 본 발명의 일 실시예에 따른 계층별 학습 파라미터 비율을 나타내는 도면이다. 도 6은 다섯 가지 계층의 훈련 매개 변수 크기와 계산 비율을 보여준다. 여기서, 다섯 가지 계층은 3 × 3 컨벌루션, 1 × 1 컨벌루션, 시프트 컨벌루션, 완전히 연결된 레이어(Fully Connected Layer;fct), 배치 정규화(Batch Normalization; bn) 이다. 6 is a diagram illustrating a learning parameter ratio for each layer according to an embodiment of the present invention. 6 shows the training parameter sizes and calculation ratios of the five layers. Here, the five layers are 3 × 3 convolution, 1 × 1 convolution, shift convolution, fully connected layer (fct), and batch normalization (bn).

도 6의 (a)는 종래의 ResNet 모델의 학습 파라미터 비율을 나타내고, 도 6의 (b)는 활성 시프트 블록 구조(ASL) 모델의 학습 파라미터 비율이며, 도 6의 (c)는 Res-IB-Shift 모델의 학습 파라미터 비율이며, 도 6의 (d)는 SSPQ 모델의 학습 파라미터 비율이다. Figure 6 (a) shows the learning parameter ratio of the conventional ResNet model, Figure 6 (b) is the learning parameter ratio of the active shift block structure (ASL) model, Figure 6 (c) is Res-IB- The ratio of the learning parameters of the Shift model, and (d) of FIG. 6 is the ratio of the training parameters of the SSPQ model.

도 6의 (a)와 도 6의 (b)를 비교하면 3 × 3 컨벌루션 연산에 필요한 학습 매개 변수의 크기가 시프트로 대체된다. Comparing Fig. 6 (a) and Fig. 6 (b), the size of the learning parameter required for the 3 × 3 convolution operation is replaced with a shift.

도 6의 (a)의 모델에서 44.208 MB 크기가 29.5kB로 99.93% 압축됨을 알 수 있다. It can be seen that in the model of (a) of Figure 6, the size of 44.208 MB is compressed 99.93% to 29.5 kB.

도 6의 (c)의 Res-IB-Shift을 도 3의 (b)의 활성 시프트 블록에 대한 신경망 구조에 적용하면 도 6의 (b)의 1 × 1 컨벌루션의 크기가 91%에서 도 6의 (c)의 1 × 1 컨벌루션에 비율은 85%로 31.09MB 감소했다. When Res-IB-Shift of FIG. 6(c) is applied to the neural network structure for the active shift block of FIG. 3(b), the size of the 1×1 convolution of FIG. For the 1 × 1 convolution in (c), the ratio was 85%, which decreased by 31.09 MB.

역 잔여 블록은 소수의 채널 사이에서 동일한 블록을 연결하고, 종래의 잔여 블록은 다수의 동일 블록을 연결한다. 따라서, 1 × 1 컨벌루션의 수가 줄어들고 정확성은 향상된다. The inverse residual block connects the same block among a few channels, and the conventional residual block connects multiple identical blocks. Therefore, the number of 1 × 1 convolutions is reduced and the accuracy is improved.

일 실시예에 따른 SSPQ는 시프트 연산으로 공간 연산을 사용하고, 네트워크 구조로 역 잔여 블록을 채택함으로써, 수학식 3 내지 6에 따라 양자화를 1 Х 1 컨벌루션에 적용하여 연산량의 크기를 줄인다. 도 6의 (c)와 (d)에서 볼 수 있듯이, 1 × 1 컨벌루션의 학습 매개 변수 크기는 약 46MB 감소하고 모델 크기는 9.78MB가 된다. SSPQ according to an embodiment uses a spatial operation as a shift operation and adopts an inverse residual block as a network structure, so that quantization is applied to 1 Х 1 convolution according to Equations 3 to 6 to reduce the size of the computation. As can be seen from (c) and (d) of Figure 6, the training parameter size of 1 × 1 convolution is reduced by about 46 MB, and the model size becomes 9.78 MB.

도 6을 참조하면, 도 6의 (d)에 도시한 역동일 연결 이동 잔여 병목 블록을 기반의 뉴럴 네트워크를 적용한 SSPQ50 모델과 도 6 (a)에 도시한 종래의 ResNet 모델의 3×3 컨벌루션과 파라미터의 크기를 비교할 때 대략 44MB 모델 크기를 줄일 수 있음을 확인할 수 있다. Referring to FIG. 6 , the 3×3 convolution of the SSPQ50 model to which a neural network based on the inverse same connection movement residual bottleneck block shown in FIG. 6(d) is applied and the conventional ResNet model shown in FIG. 6(a) and When comparing the size of the parameters, it can be seen that the size of the model can be reduced by approximately 44 MB.

도 6의 (d)에 도시한 본 발명의 일 실시예에 따른 역동일 연결 이동 잔여 병목 블록을 기반의 뉴럴 네트워크를 적용한 SSPQ모델은 이러한 3×3 컨벌루션 계층을 이동(shift) 계층으로 대체하면서 동시에 1x1 컨벌루션 계층에 양자화를 적용한다. 여기서 양자화는 1×1 지점화 컨벌루션에만 양자화를 적용하되, 가중치 양자화에는 1 비트를 그리고 활성함수 양자화에는 4 비트를 사용 하였으며, 가중치 양자화 후에는 배치 정규화(batch normalization)을 적용한다. 이와 같이, 가중치 양자화 후에 배치 정규화를 수행함으로써 정확도 손실을 줄일 수 있다. The SSPQ model to which a neural network based on the inverse same connection movement residual bottleneck block according to an embodiment of the present invention shown in FIG. Apply quantization to a 1x1 convolutional layer. Here, quantization is applied only to 1×1 branched convolution, but 1 bit is used for weight quantization and 4 bits are used for activation function quantization, and batch normalization is applied after weight quantization. In this way, accuracy loss can be reduced by performing batch normalization after weight quantization.

배치 정규화는 각 층의 활성화 함수의 출력값 분포가 골고루 분포되도록 강제하는 방법으로서, 각 층에서의 활성화 함수 출력값이 정규분포를 이루도록 조정하는 방법이다. 이를 위하여, 각 피쳐 별 평균(mean)과 분산(variance)를 구한 후 정규화할 수 있다. 이때 평균은 0, 분산이 1이되도록 할 수 있다. Batch normalization is a method of forcing the output value distribution of the activation function of each layer to be evenly distributed, and is a method of adjusting the output value of the activation function in each layer to achieve a normal distribution. To this end, the mean and variance for each feature may be obtained and then normalized. In this case, the mean may be 0 and the variance may be 1.

도 6의 각각의 모델에 대한 IMAGENET 데이터 세트에 대한 깊이 50 모델의 성능을 표 1에 나타내었다. Table 1 shows the performance of the depth 50 model on the IMAGENET data set for each model in FIG. 6 .

[표 1] [Table 1]

Figure pat00009
Figure pat00009

표 1에 도시한 바와 같이, 도 6의 (b)의 ASL50 model 의 총 사이즈는 도 6의 (a)의 ResNet50과 비교하여 97.49MB에서 84.74MB로 약 12.75MB 감소하였다. 도 6의 (d)의 SSPQ50의 모델과 도 6의 (c) ResIBShift50 모델을 비교하면 학습 파라미터의 수는 감소하지 않았다. 이는 양자화 후 연산이 32 비트로 계산되기 때문에 총 학습 매개 변수의 수가 감소하지 않은 것이다. 그러나, 본 발명의 일 실시예에 따른 의 SSPQ50에 대해 32b float 가 아닌 1비트로 양자화후 연산을 수행하면 97.49MB는 9.78 MB가 되고 도 6의 (a)의 ResNet50에 비해 모델크기가 87.71 MB 감소한다. As shown in Table 1, the total size of the ASL50 model of FIG. 6(b) was reduced by about 12.75MB from 97.49MB to 84.74MB compared to the ResNet50 of FIG. 6(a). When the SSPQ50 model of FIG. 6 (d) and the ResIBShift50 model of FIG. 6 (c) were compared, the number of learning parameters did not decrease. This is because the number of total learning parameters does not decrease because the operation after quantization is computed in 32 bits. However, if quantization is performed with 1 bit instead of 32b float on SSPQ50 of according to an embodiment of the present invention, 97.49 MB becomes 9.78 MB, and the model size is reduced by 87.71 MB compared to ResNet50 of FIG. 6(a). .

도 7은 본 발명의 다른 실시예에 따른 뉴럴 네트워크 연산 방법을 설명하기 위한 도면이다. 7 is a diagram for explaining a neural network calculation method according to another embodiment of the present invention.

도 7을 참조하면, 본 발명의 다른 실시예에 따른 뉴럴 네트워크 연산 방법은 SSPLQ 모델에 따라 제1 단계와 제2 단계로 구분된다. 제1 단계는 도 2 내지 도 6을 참조하여 설명한 일 실시예에 따른 SSPQ 모델에 기초한 뉴럴 네트워크 연산 방법과 동일하다. 2단계는 선형 계층의 변형방법이다. Referring to FIG. 7 , the neural network calculation method according to another embodiment of the present invention is divided into a first step and a second step according to the SSPLQ model. The first step is the same as the method for calculating a neural network based on the SSPQ model according to an embodiment described with reference to FIGS. 2 to 6 . Step 2 is the transformation method of the linear layer.

SSPQ 모델의 마지막 계층은 역동일 연결 이동 잔여 병목 블록 뒤에 평균 통합(Average Pooling) 계층과 완전연결계층이 연결된다.In the last layer of the SSPQ model, the average pooling layer and the fully connected layer are connected behind the remaining bottleneck block of the inverse same connection movement.

블록별로 채널을 4배씩 확장하는 구조를 띄고 있는 관계로 전 계층의 각 블록의 채널수는 [64, 128, 256, 512]와 해당 채널수를 갖는 블록의 수는 [3, 4, 6, 3]이다. 따라서 마지막 선형 계층, 완전연결계층 바로 이전의 블록의 출력은 512채널이 4배로 확장된 2048 채널 출력이 된다. SSLPQ의 마지막 단계는 도 7의 (b), 상대적으로 SSPQ의 마지막 단계는 도 7의 (a)와 같다. 도 7의 (a)와 도 7의 (b)를 비교하여 확인 할 수 있듯이, 4 계층으로 구성된 마지막 한 블록이 생략되고, 이전 블록의 출력인 2048 출력 채널 값을 입력으로 받고 이를 1bit 양자화 함수를 거친 가중치를 기반으로 1×1 컨벌루션을 수행한다. 이를 정규화 과정을 거친 후, 4bit 양자화 함수를 통과시킨 활성함수 결과는 이전의 평균 통합과정에게 넘겨주었던 2048 채널수의 1/4이 된 512채널수가 된다. 이 512채널을 입력으로 평균 통합(Average Pooling) 과정 후, 활성함수를 다시 지나 4 비트 양자화를 수행 후, 이를 선형 계층에서 완전연결계층으로 ImageNet 1000 클래스를 구성한다. 이를 소프트맥스(softmax) 함수를 통해 입력 이미지에 대한 분류 연산이 진행된다. 도 6의 (a)와 같이 SSPLQ50는 SSPQ50의 모델 크기 대비 16.27%로, 그리고 기준모델인 ResNet50 대비 3.56%의 크기에 해당하는 3.55MB크기로 73.87%의 성능을 얻을 수 있었다. 모델 크기의 단축으로 학습시간도 SSPQ 모델이 ILSVRC 2012 ImageNet dataset의 128만장의 학습 이미지들을 256 배치 사이즈로 학습시키는데 평균 5일이 걸렸는데, 이를 SSPLQ 모델을 통 해 4일로 20% 단축할 수 있었다.As each block has a structure in which the channel is expanded by 4 times, the number of channels in each block of the previous layer is [64, 128, 256, 512] and the number of blocks with the corresponding number of channels is [3, 4, 6, 3] ]to be. Therefore, the output of the block just before the last linear layer and fully connected layer becomes a 2048 channel output with 512 channels expanded 4 times. The last step of SSLPQ is shown in (b) of FIG. 7, and the last step of SSPQ is relatively as shown in FIG. 7 (a). As can be seen by comparing Fig. 7 (a) and Fig. 7 (b), the last one block composed of 4 layers is omitted, and 2048 output channel value, which is the output of the previous block, is received as an input and a 1-bit quantization function is applied. 1×1 convolution is performed based on coarse weights. After the normalization process, the result of the activation function passing the 4-bit quantization function becomes the number of 512 channels, which is 1/4 of the number of 2048 channels passed to the previous average integration process. After the average pooling process with these 512 channels as an input, 4 bit quantization is performed through the activation function again, and the ImageNet 1000 class is configured from the linear layer to the fully connected layer. A classification operation is performed on the input image through the softmax function. As shown in (a) of FIG. 6, SSPLQ50 was 16.27% compared to the model size of SSPQ50, and 73.87% performance was obtained with 3.55MB size corresponding to the size of 3.56% compared to ResNet50, which is the reference model. As for the training time due to the reduction in model size, it took an average of 5 days for the SSPQ model to train 1.28 million training images of the ILSVRC 2012 ImageNet dataset in 256 batch sizes, which was reduced by 20% to 4 days with the SSPLQ model.

일 실시예에서, 최적의 학습률을 찾기 위해 학습률을 조정하는 코사인 학습률을 채택하였다. 코사인 학습률은 초기에 큰 값으로 설정한 다음 작은 값으로 감소시킨다. 수학식 7에서 코사인 학습율은 Nestrov optimizer를 사용하여 최적화하였다. 에포치 e는 웜업(warm-up) 길이 Tw이 되는 동안, 즉,

Figure pat00010
이 설정된다. 스텝 사이즈 S에 도달할 때, ηt는 수학식 7을 사용하여 주기적으로 업데이트된다. In one embodiment, a cosine learning rate is employed that adjusts the learning rate to find the optimal learning rate. The cosine learning rate is initially set to a large value and then decreased to a small value. In Equation 7, the cosine learning rate was optimized using a Nestrov optimizer. The epoch e is the warm-up length Tw, i.e.,
Figure pat00010
This is set When the step size S is reached, η t is updated periodically using equation (7).

[수학식 7] [Equation 7]

Figure pat00011
Figure pat00011

ηt의 최소값은 너무 작아서 업데이트되지 않는 문제를 방지하기 위해 최소값 ηmin으로 설정해둔다. The minimum value of η t is set to the minimum value η min to avoid the problem of not being updated because it is too small.

수학식 7에서, Tm은 최대 기간(최대 에포치)이고, Tw는 웜-업 에포치 길이이고, et는 t번째 학습의 에포치이다. In Equation 7, Tm is the maximum duration (maximum epoch), Tw is the warm-up epoch length, and et is the epoch of t-th learning.

일 실시예에 따른 2단계 양자화 방법의 알고리즘은 하기와 같다. An algorithm of the two-step quantization method according to an embodiment is as follows.

Figure pat00012
Figure pat00012

상기 알고리즘에 나타난 바와 같이, 양자화로 인한 손실을 줄이기 위하여, 첫번째 학습시 가중치만 양자화 bit를 적용하고, 두번째 학습을 시작할 때는 훈련된 매개변수를 기반으로 가중치 및 활성 함수 모두를 1 bit, 4bit 로 양자화하여 학습을 하되, 첫번재 학습에서 학습된 가중치 파라미터들과 하이퍼 파라미터인 학습율을 활용하여 학습한다. 두번째 학습은 1 에포치만 학습하여도 향상된 성능을 얻을 수 있다. As shown in the above algorithm, in order to reduce the loss due to quantization, quantization bits are applied only to the weights during the first learning, and when starting the second learning, both the weights and the activation functions are quantized to 1 bit and 4 bits based on the trained parameters. to learn, but by using the weight parameters learned in the first learning and the learning rate, which is a hyperparameter, to learn. In the second training, improved performance can be obtained by learning only 1 epoch.

이 때, 처리 흐름도 도면들의 각 블록과 흐름도 도면들의 조합들은 컴퓨터 프로그램 인스트럭션들에 의해 수행될 수 있음을 이해할 수 있을 것이다. 이 컴퓨터 프로그램 인스트럭션들은 범용 컴퓨터, 특수용 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비의 프로세서에 탑재될 수 있으므로, 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비의 프로세서를 통해 수행되는 그 인스트럭션들이 흐름도 블록(들)에서 설명된 기능들을 수행하는 수단을 생성하게 된다. 이들 컴퓨터 프로그램 인스트럭션들은 특정 방식으로 기능을 구현하기 위해 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비를 지향할 수 있는 컴퓨터 이용 가능 또는 컴퓨터 판독 가능 메모리에 저장되는 것도 가능하므로, 그 컴퓨터 이용가능 또는 컴퓨터 판독 가능 메모리에 저장된 인스트럭션들은 흐름도 블록(들)에서 설명된 기능을 수행하는 인스트럭션 수단을 내포하는 제조 품목을 생산하는 것도 가능하다. 컴퓨터 프로그램 인스트럭션들은 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비 상에 탑재되는 것도 가능하므로, 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비 상에서 일련의 동작 단계들이 수행되어 컴퓨터로 실행되는 프로세스를 생성해서 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비를 수행하는 인스트럭션들은 흐름도 블록(들)에서 설명된 기능들을 실행하기 위한 단계들을 제공하는 것도 가능하다.At this time, it will be understood that each block of the flowchart diagrams and combinations of the flowchart diagrams may be performed by computer program instructions. These computer program instructions may be embodied in a processor of a general purpose computer, special purpose computer, or other programmable data processing equipment such that the instructions performed by the processor of the computer or other programmable data processing equipment may be described in the flowchart block(s). It creates a means to perform functions. These computer program instructions may also be stored in a computer-usable or computer-readable memory that may direct a computer or other programmable data processing equipment to implement a function in a particular manner, and thus the computer-usable or computer-readable memory. It is also possible for the instructions stored in the flowchart block(s) to produce an article of manufacture containing instruction means for performing the function described in the flowchart block(s). The computer program instructions may also be mounted on a computer or other programmable data processing equipment, such that a series of operational steps are performed on the computer or other programmable data processing equipment to create a computer-executed process to create a computer or other programmable data processing equipment. It is also possible that instructions for performing the processing equipment provide steps for performing the functions described in the flowchart block(s).

또한, 각 블록은 특정된 논리적 기능(들)을 실행하기 위한 하나 이상의 실행 가능한 인스트럭션들을 포함하는 모듈, 세그먼트 또는 코드의 일부를 나타낼 수 있다. 또, 몇 가지 대체 실행 예들에서는 블록들에서 언급된 기능들이 순서를 벗어나서 발생하는 것도 가능함을 주목해야 한다. 예컨대, 잇달아 도시되어 있는 두 개의 블록들은 사실 실질적으로 동시에 수행되는 것도 가능하고 또는 그 블록들이 때때로 해당하는 기능에 따라 역순으로 수행되는 것도 가능하다.Additionally, each block may represent a module, segment, or portion of code that includes one or more executable instructions for executing specified logical function(s). It should also be noted that in some alternative implementations it is also possible for the functions recited in the blocks to occur out of order. For example, it is possible that two blocks shown in succession are actually performed substantially simultaneously, or that the blocks are sometimes performed in the reverse order according to the corresponding function.

이 때, 본 실시 예에서 사용되는 '~부'라는 용어는 소프트웨어 또는 FPGA또는 ASIC과 같은 하드웨어 구성요소를 의미하며, '~부'는 어떤 역할들을 수행한다. 그렇지만 '~부'는 소프트웨어 또는 하드웨어에 한정되는 의미는 아니다. '~부'는 어드레싱할 수 있는 저장 매체에 있도록 구성될 수도 있고 하나 또는 그 이상의 프로세서들을 재생시키도록 구성될 수도 있다. 따라서, 일 예로서 '~부'는 소프트웨어 구성요소들, 객체지향 소프트웨어 구성요소들, 클래스 구성요소들 및 태스크 구성요소들과 같은 구성요소들과, 프로세스들, 함수들, 속성들, 프로시저들, 서브루틴들, 프로그램 코드의 세그먼트들, 드라이버들, 펌웨어, 마이크로코드, 회로, 데이터, 데이터베이스, 데이터 구조들, 테이블들, 어레이들, 및 변수들을 포함한다. 구성요소들과 '~부'들 안에서 제공되는 기능은 더 작은 수의 구성요소들 및 '~부'들로 결합되거나 추가적인 구성요소들과 '~부'들로 더 분리될 수 있다. 뿐만 아니라, 구성요소들 및 '~부'들은 디바이스 또는 보안 멀티미디어카드 내의 하나 또는 그 이상의 CPU들을 재생시키도록 구현될 수도 있다.At this time, the term '~ unit' used in this embodiment means software or hardware components such as FPGA or ASIC, and '~ unit' performs certain roles. However, '-part' is not limited to software or hardware. '~unit' may be configured to reside on an addressable storage medium or may be configured to refresh one or more processors. Thus, as an example, '~' denotes components such as software components, object-oriented software components, class components, and task components, and processes, functions, properties, and procedures. , subroutines, segments of program code, drivers, firmware, microcode, circuitry, data, databases, data structures, tables, arrays, and variables. The functions provided in the components and '~ units' may be combined into a smaller number of components and '~ units' or further separated into additional components and '~ units'. In addition, components and '~ units' may be implemented to play one or more CPUs in a device or secure multimedia card.

본 명세서가 속하는 기술분야의 통상의 지식을 가진 자는 본 명세서가 그 기술적 사상이나 필수적인 특징을 변경하지 않고서 다른 구체적인 형태로 실시될 수 있다는 것을 이해할 수 있을 것이다. 그러므로 이상에서 기술한 실시 예들은 모든 면에서 예시적인 것이며 한정적이 아닌 것으로 이해해야만 한다. 본 명세서의 범위는 상기 상세한 설명보다는 후술하는 특허청구의 범위에 의하여 나타내어지며, 특허청구의 범위의 의미 및 범위 그리고 그 균등 개념으로부터 도출되는 모든 변경 또는 변형된 형태가 본 명세서의 범위에 포함되는 것으로 해석되어야 한다.Those of ordinary skill in the art to which this specification belongs will be able to understand that the present specification may be embodied in other specific forms without changing the technical spirit or essential features thereof. Therefore, it should be understood that the embodiments described above are illustrative in all respects and not restrictive. The scope of the present specification is indicated by the claims described later rather than the detailed description, and all changes or modifications derived from the meaning and scope of the claims and their equivalent concepts are included in the scope of the present specification. should be interpreted

한편, 본 명세서와 도면에는 본 명세서의 바람직한 실시 예에 대하여 개시하였으며, 비록 특정 용어들이 사용되었으나, 이는 단지 본 명세서의 기술 내용을 쉽게 설명하고 발명의 이해를 돕기 위한 일반적인 의미에서 사용된 것이지, 본 명세서의 범위를 한정하고자 하는 것은 아니다. 여기에 개시된 실시 예 외에도 본 명세서의 기술적 사상에 바탕을 둔 다른 변형 예들이 실시 가능하다는 것은 본 명세서가 속하는 기술 분야에서 통상의 지식을 가진 자에게 자명한 것이다. On the other hand, in the present specification and drawings, preferred embodiments of the present specification have been disclosed, and although specific terms are used, these are only used in a general sense to easily explain the technical content of the present specification and help the understanding of the present invention, It is not intended to limit the scope of the specification. It will be apparent to those of ordinary skill in the art to which this specification pertains that other modifications based on the technical spirit of the present specification may be implemented in addition to the embodiments disclosed herein.

Claims (10)

뉴럴 네트워크 연산 장치의 뉴럴 네트워크 연산 방법으로서,
입력 데이터를 깊이 방향으로 분리하여 미리 연산된 기울기에 따라 시프트하는 단계; 및
시프트된 데이터의 지점 화 컨벌루션(point-wise convolution)에 양자화를 적용하는 단계
를 포함하는 뉴럴 네트워크 연산 방법.
A neural network computation method of a neural network computation device, comprising:
separating the input data in the depth direction and shifting the input data according to a pre-calculated gradient; and
applying quantization to a point-wise convolution of the shifted data;
A neural network computation method comprising
제1항에 있어서,
상기 양자화를 적용하는 단계는 상기 시프트된 데이터를 쌍곡 탄젠트(hyperbolic tangent)에 기초하여 전처리하고, 양자화된 가중치와 양자화된 가중치의 기울기를 연산하는 것을 특징으로 하는 뉴럴 네트워크 연산 방법.
According to claim 1,
The applying of the quantization comprises preprocessing the shifted data based on a hyperbolic tangent, and calculating a quantized weight and a gradient of the quantized weight.
제1항에 있어서,
상기 양자화를 적용하는 단계는 소수의 채널 사이에서 동일한 블록을 연결하는 역잔여 블록을 채택하는 것을 특징으로 하는 뉴럴 네트워크 연산 방법.
According to claim 1,
The step of applying the quantization comprises adopting an inverse residual block that connects the same block among a small number of channels.
제1항에 있어서,
상기 양자화를 적용하는 단계는,
활성함수의 양자화비트를 4비트로 제한하고, 가중치의 양자화비트를 1비트로 제한하는 것을 특징으로 하는 뉴럴 네트워크 연산 방법.
According to claim 1,
The step of applying the quantization is
A neural network calculation method, characterized in that the quantization bit of the activation function is limited to 4 bits and the quantization bit of the weight is limited to 1 bit.
제4항에 있어서,
상기 양자화를 적용하는 단계 이후에는 각 피쳐 별 평균(mean)과 분산(variance)에 기초하여 배치 정규화(batch normalization)를 수행하는 단계
를 더 포함하는 것을 특징으로 하는 뉴럴 네트워크 연산 방법.
5. The method of claim 4,
After applying the quantization, batch normalization is performed based on the mean and variance of each feature.
Neural network calculation method, characterized in that it further comprises.
제4항에 있어서,
상기 미리 연산된 기울기는 뉴럴 네트워크의 손실함수를 최적화하는 방향으로 연산되는 것을 특징으로 하는 뉴럴 네트워크 연산 방법.
5. The method of claim 4,
The pre-computed gradient is calculated in the direction of optimizing the loss function of the neural network.
제1항에 있어서,
양자화된 데이터를 정규화(normalization)하고, 평균 통합(average Pooling) 하여, 활성함수를 적용한 후, 선형계층에서 완전연결하는 단계를 더 포함하는 것을 특징으로 하는 뉴럴 네트워크 연산 방법.
According to claim 1,
Normalizing the quantized data, performing average pooling, applying an activation function, and then completely connecting the quantized data in a linear layer.
제6항에 있어서,
상기 손실함수는 웜업(warm-up) 길이와 스텝 사이즈(step-size)를 하이퍼 파라미터로 하는 코사인 학습율과 Nestrov 최적화 알고리즘을 결합하여 최적화하는 것을 특징으로 하는 뉴럴 네트워크 연산 방법.
7. The method of claim 6,
The loss function is a neural network computation method, characterized in that it is optimized by combining a cosine learning rate using a warm-up length and a step-size as hyper parameters and a Nestrov optimization algorithm.
제8항에 있어서,
첫번째 학습시에는 가중치에만 양자화 비트를 적용하여 전체 에포치에 대해 학습하고, 두번째 학습시에는 가중치와 활성함수를 모두 양자화하여 학습을 수행하는 것을 특징으로 하는 뉴럴 네트워크 연산 방법.
9. The method of claim 8,
In the first learning, the quantization bit is applied only to the weights to learn the entire epoch, and in the second learning, the learning is performed by quantizing both the weights and the activation function.
컴퓨터 프로그램이 프로세서에 의해 실행될 때, 제1항 내지 제9항 중 어느 한 항에 따른 방법이 수행되는 컴퓨터 프로그램을 저장한 컴퓨터-판독가능 저장 매체.

A computer-readable storage medium storing a computer program in which the method according to any one of claims 1 to 9 is performed when the computer program is executed by a processor.

KR1020210018472A 2021-02-09 2021-02-09 Method for computing neural network using ruduction-repetition block and apparatus using the same KR20220114890A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
KR1020210018472A KR20220114890A (en) 2021-02-09 2021-02-09 Method for computing neural network using ruduction-repetition block and apparatus using the same
PCT/KR2021/016682 WO2022173095A1 (en) 2021-02-09 2021-11-15 Neural network calculation method and apparatus therefor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020210018472A KR20220114890A (en) 2021-02-09 2021-02-09 Method for computing neural network using ruduction-repetition block and apparatus using the same

Publications (1)

Publication Number Publication Date
KR20220114890A true KR20220114890A (en) 2022-08-17

Family

ID=82837846

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020210018472A KR20220114890A (en) 2021-02-09 2021-02-09 Method for computing neural network using ruduction-repetition block and apparatus using the same

Country Status (2)

Country Link
KR (1) KR20220114890A (en)
WO (1) WO2022173095A1 (en)

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107844828B (en) * 2017-12-18 2021-07-30 南京地平线机器人技术有限公司 Convolution calculation method in neural network and electronic device
KR102017998B1 (en) * 2018-01-16 2019-09-03 한국과학기술원 A method and apparatus of image pipeline processing
CN110390383B (en) * 2019-06-25 2021-04-06 东南大学 Deep neural network hardware accelerator based on power exponent quantization

Also Published As

Publication number Publication date
WO2022173095A1 (en) 2022-08-18

Similar Documents

Publication Publication Date Title
Paszke et al. Enet: A deep neural network architecture for real-time semantic segmentation
Mehta et al. Espnet: Efficient spatial pyramid of dilated convolutions for semantic segmentation
US11574195B2 (en) Operation method
CN110059710B (en) Apparatus and method for image classification using convolutional neural network
Singh et al. Leveraging filter correlations for deep model compression
CN107516129B (en) Dimension self-adaptive Tucker decomposition-based deep network compression method
US10949737B2 (en) Method for neural network and apparatus performing same method
US20180218518A1 (en) Data compaction and memory bandwidth reduction for sparse neural networks
US11847569B2 (en) Training and application method of a multi-layer neural network model, apparatus and storage medium
US11797855B2 (en) System and method of accelerating execution of a neural network
CN111095302A (en) Compression of sparse deep convolutional network weights
CN109389667B (en) High-efficiency global illumination drawing method based on deep learning
US11775832B2 (en) Device and method for artificial neural network operation
CN113222102B (en) Optimization method for neural network model quantization
US20210073644A1 (en) Compression of machine learning models
CN114821058A (en) Image semantic segmentation method and device, electronic equipment and storage medium
Qi et al. Learning low resource consumption cnn through pruning and quantization
WO2024060839A1 (en) Object operation method and apparatus, computer device, and computer storage medium
Park et al. Squantizer: Simultaneous learning for both sparse and low-precision neural networks
KR20220114890A (en) Method for computing neural network using ruduction-repetition block and apparatus using the same
WO2022095984A1 (en) Method and system for convolution with workload-balanced activation sparsity
US11699077B2 (en) Multi-layer neural network system and method
CN116457794A (en) Group balanced sparse activation feature map for neural network model
Khan et al. Binarized convolutional neural networks for efficient inference on GPUs
Solovyev et al. Real-Time Recognition of Handwritten Digits in FPGA Based on Neural Network with Fixed Point Calculations

Legal Events

Date Code Title Description
E902 Notification of reason for refusal
AMND Amendment
E601 Decision to refuse application
X091 Application refused [patent]
AMND Amendment
X601 Decision of rejection after re-examination