WO2022097954A1 - Neural network computation method and neural network weight generation method - Google Patents

Neural network computation method and neural network weight generation method Download PDF

Info

Publication number
WO2022097954A1
WO2022097954A1 PCT/KR2021/014367 KR2021014367W WO2022097954A1 WO 2022097954 A1 WO2022097954 A1 WO 2022097954A1 KR 2021014367 W KR2021014367 W KR 2021014367W WO 2022097954 A1 WO2022097954 A1 WO 2022097954A1
Authority
WO
WIPO (PCT)
Prior art keywords
layer
neural network
value
output
input
Prior art date
Application number
PCT/KR2021/014367
Other languages
French (fr)
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 오픈엣지테크놀로지 주식회사
Publication of WO2022097954A1 publication Critical patent/WO2022097954A1/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
    • 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

Definitions

  • the present invention relates to computing technology, and more particularly, to an operation structure inside a neural network and a method of generating parameters provided therefor.
  • the neural network 2 has a structure including an input layer, hidden layers, and an output layer, performs an operation based on received input data I1 and I2 , and outputs data based on the result of the execution. (O1 and O2) can be formed.
  • 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 a neuron, a processing element (PE), a unit, or similar terms.
  • PE processing element
  • Channels included in each of the layers of the neural network 2 may be connected to each other to process data.
  • one channel may perform an operation by receiving data from other channels, and may output an operation result to other channels.
  • each of the layers 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 and weights received from channels included in the previous layer.
  • the weight is a parameter used to calculate output activation in each layer, and may be a value assigned to a connection relationship between layers.
  • activation of one input data can have c certain values for each coordinate (two-dimensional in x and y in the case of an image), and the axis for these c values can be expressed as a channel axis.
  • one input may be composed of (coordinates*channel) data.
  • activation for image processing can be composed of four dimensions such as (batch, x, y, channel). .
  • a batch may mean a dimension representing input 0, input 1, input 2, and the like.
  • Each of the channels may be processed by a computational unit or processing element that receives an input and outputs an output activation, and an input-output of each of the channels may be mapped.
  • is an activation function
  • w i jk 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
  • b i j is If it is the bias of the j-th channel included in the i-th layer
  • a i j is the activation of the j-th channel in the i-th layer
  • activation of the first channel CH 1 of the second layer Layer 2 may be expressed as a 2 1 .
  • Equation 1 described above is only an example for explaining the activation and weight used to process data in the neural network 2 , and is not limited thereto.
  • Activation may be a value obtained by passing a value obtained by applying an activation function to the sum of activations received from the previous layer through a Rectified Linear Unit (ReLU).
  • ReLU Rectified Linear Unit
  • the neural network quantization apparatus proposed in the above-mentioned prior art generates a neural network, trains (or learns) a neural network, quantizes a floating-point type neural network into a fixed-point type neural network, or regenerates a neural network. It performs various processing functions, such as functions to train (retrain).
  • a trained neural network can be generated by repeatedly training (learning) a given initial neural network.
  • the initial neural network may have floating-point type parameters in order to secure processing accuracy of the neural network.
  • the floating point requires a relatively large amount of computation and a large memory access frequency compared to the fixed point.
  • processing of a neural network having floating-point type parameters may not be smooth in a mobile device, an embedded device, or the like, which has relatively low processing performance.
  • the floating-point type parameters are preferably quantized.
  • parameter quantization means converting a floating-point type parameter into a fixed-point type parameter.
  • the neural network quantization apparatus performs quantization by converting parameters of a trained neural network into a fixed-point type of predetermined bits, and transmits the quantized neural network to a device to be employed.
  • the performance or efficiency of the hardware accelerator may be improved.
  • An object of the present invention is to provide a technique capable of reducing hardware complexity of a computing device processing a neural network, increasing processing speed, or improving resource utilization.
  • I A denotes an input activation
  • O A denotes an output activation
  • w denotes a weight parameter
  • a hardware accelerator may be implemented to convert an input activation, an output activation, and a weight into integers in a fixed point form and process the operation through an integer operator.
  • I A , O A , w may be defined as shown in the following equation and FIG. 3A .
  • the scale value is determined so that the q value has sufficient resolution in the form of an n-bit integer, and the floating-point value can be converted into the fixed-point format of the integer form through the /scale and quantize process.
  • S I , S w , and S O values are commonly used values within one layer or a specific channel of one activation . , but in the case of q S , it is commonly used within a layer or within a specific channel of one activation.
  • a fixed-point-based quantized arithmetic method of the form shown in FIG. 4 is provided as a method for making simpler hardware while exhibiting an operation effect similar to that shown in FIGS. 2, 3A, and 3B.
  • one multiplier can be reduced for each multiplication, there is an advantage in that hardware of a smaller size can be made.
  • the present invention includes a quantization algorithm for generating a weight parameter q' w for the above quantization operation.
  • This algorithm is an algorithm that premultiplies the weight with S I /S O and then converts it to a fixed-point integer.
  • a computing device comprising a data operation unit that executes an operation of a specific layer of an integer type neural network including an input layer, an intermediate layer, and an output layer, and an internal memory that provides data for operation to the data operation unit can do.
  • the specific layer is the first layer belonging to the intermediate layer part or the output layer
  • the first node included in the first layer includes a set of input activations input to the first node and a set of activations.
  • a set of multipliers each multiplying a set of weights corresponding to s; an adder for adding the outputs of the set of multipliers to each other; and a shift unit converting the output of the adder to generate output activation of the first node.
  • each of the set of input activations and the set of weights may be n-bit integer data, and the shift unit may be configured to right-shift the output of the adder by n bits.
  • the second node included in the input layer converts activation having a real value input to the second node into activation having an integer value using a predetermined input scaling factor. may be adapted to be converted.
  • the computing device may further include a scaling unit that converts and outputs the activation output by the output layer using a predetermined output scaling factor.
  • the input scaling factor, the output scaling factor, and the one set of weights may be provided by the computing device from another computing device. and the other computing device is configured to use information about a neural network having a structure corresponding to the integer neural network, and to generate the input scaling factor assigned to an input layer of the original neural network, - generate the output scaling factor assigned to an output layer of a neural network, and generate scaling factors assigned to each of the intermediate layers defined between the input layer and the output layer in the original-neural network, dividing the Lth scaling factor assigned to the Lth layer directly upstream of the L+1th layer including the node corresponding to the first node by the L+1th scaling factor assigned to the L+1th layer in A first value is calculated, and the weight (w.ab Layer_L ) assigned to the link (link ab Layer_L ) connected from the node having the index b of the Lth layer to the node having the index a of the L+1th layer is added to the multiply the first value to calculate a second value, multiply the second value by 2
  • a terminal including a processing unit and a storage unit drives a neural network to generate an output activation of the first node included in the intermediate layer or the output layer of an integer neural network including an input layer, an intermediate layer, and an output layer method can be provided.
  • the neural network driving method may include: obtaining, by the processing unit, a set of input activations from the storage unit, and acquiring a set of weights corresponding to the set of input activations from the storage unit; a multiplication step in which the processing unit multiplies the one set of weights and the values corresponding to each other of the one set of input activations to calculate a set of first values; an adding step in which the processing unit adds the set of first values to each other to calculate a second value; and a shifting step in which the processing unit calculates the output activation of the first node by right-shifting the second value by n bits.
  • each of the set of input activations and the set of weights may be n-bit integer data.
  • the method of driving the neural network includes: converting, by the processor, an activation having a real value input to a second node belonging to the input layer into an activation having an integer value using a predetermined input scaling factor; and converting, by the processing unit, the activation output from the output layer using a predetermined output scaling factor.
  • the input scaling factor, the output scaling factor, and the set of weights may be provided by the terminal from another computing device.
  • the other computing device is configured to use information about a one-neural network having a structure corresponding to the integer neural network, and to generate the input scaling factor assigned to an input layer of the original-neural network, generate the output scaling factor assigned to an output layer of a neural network, and generate scaling factors assigned to each of the intermediate layers defined between the input layer and the output layer in the original neural network, wherein in the original neural network
  • the L-th scaling factor allocated to the L-th layer directly upstream of the L+1-th layer including the node corresponding to the first node is divided by the L+1-th scaling factor allocated to the L+1-th layer to obtain a A value of 1 is calculated, and the weight (w.ab Layer_L ) assigned to the link (link ab Layer_L ) connected from the node having the index b of the Lth layer to the node having the index a of the L+1th layer is added to the weight
  • a second value is calculated by multiplying the value by 1
  • a third value is calculated by multiplying the second value by 2 n
  • a fourth value is generated by approximating the third value to an integer value.
  • the fourth value may be a weight (q' w.ab layer_L ) of the integer neural network corresponding to the weight ( w.ab Layer_L ) .
  • a server generates an input scaling factor assigned to the input layer of a neural network having an input layer, an intermediate layer part, and an output layer, and generates an output scaling factor assigned to the output layer, and the intermediate layer generating scaling factors assigned to each layer of negative; and the server assigns the Lth scaling factor assigned to the Lth layer directly upstream of the L+1th layer including the first node included in the intermediate layer unit or the output layer to the L+1th layer.
  • a weight assigned to a link (link ab Layer_L ) connected from a node having an index b of the L-th layer to a node having an index a of the L+1 layer to calculate a first value by dividing by the L+1 scaling factor ( w .ab Layer_L ) is multiplied by the first value to calculate a second value, the second value is multiplied by 2 n to calculate a third value, and the third value is approximated to an integer value to generate a fourth value may include;
  • the fourth value may be a weight (q' w.ab layer_L ) of the integer neural network corresponding to the weight (w .ab Layer_L ).
  • the integer neural network information processing method may further include the step of providing, by the server, the input scaling factor, the output scaling factor, and a weight of the integer neural network to a computing device executing the operation of the integer neural network.
  • the present invention it is possible to provide a technology capable of reducing hardware complexity of a computing device processing a neural network, increasing processing speed, or improving resource utilization.
  • the neural network when the neural network is implemented as hardware, it is possible to provide a technique for reducing the complexity of the structure of each computation node in the neural network.
  • the neural network when the neural network is implemented as software, it is possible to provide a technique for simplifying the computation algorithm in each computation node in the neural network.
  • 1 is a diagram for explaining an operation performed in a neural network according to an embodiment.
  • 3A and 3B are conceptual diagrams presented to explain the creative process of the present invention.
  • FIG. 5 illustrates an example of the structure of a neural network executed in a terminal provided according to an embodiment of the present invention.
  • FIG. 6 shows a method of generating an output activation at each node of the input layer of the neural network shown in FIG. 5 .
  • FIG. 7 shows a method of generating an output activation at each node of an intermediate layer (hidden layer) of the neural network shown in FIG. 5 .
  • FIG. 8 shows an output generation method at each node of the intermediate layer (hidden layer) of the neural network shown in FIG. 5 .
  • FIG. 9 shows an output generation method at each node of the output layer of the neural network shown in FIG. 5 .
  • FIG. 10 is a diagram illustrating a method of restoring a target value from an output integer value output from each node of the output layer of the neural network shown in FIG. 5 .
  • 11 shows information provided by the server to the terminal.
  • FIG. 12 shows the structure of a neural network that has been trained by the server.
  • the neural network shown in FIG. 12 has a structure corresponding to the neural network shown in FIG. 5 .
  • FIG. 13A is a block diagram illustrating a hardware configuration of a server according to an embodiment of the present invention.
  • 13B is a diagram for explaining the quantization of a pre-trained neural network according to an embodiment of the present invention and employing it in a terminal (hardware accelerator).
  • FIG. 14 is a diagram illustrating a neural network calculation method in a terminal provided according to a comparative embodiment.
  • FIG. 5 illustrates an example of the structure of a neural network executed in a terminal provided according to an embodiment of the present invention.
  • the neural network 420 may be implemented as hardware or software within the terminal 200 .
  • the neural network 420 may include a plurality of layers (layer 1, layer 2, layer 3, layer 4). Each layer may include one or a plurality of operation nodes. In the example shown in FIG. 5 , the input layer includes two nodes and the output layer includes one node. In FIG. 5, each node is expressed as a rectangle including the letter N.
  • a value input to each node of the input layer (layer 1) may be a real value in the form of a floating point or a fixed point.
  • each node of the input layer (layer 1) may convert the real value into an integer value and output it.
  • a value input to each node of the input layer (layer 1) may be an integer type.
  • each node of each layer is an integer value and can be expressed in integer or fixed-point format.
  • the weight assigned to the link connecting each node is also an integer value, and may be expressed in an integer or fixed-point format.
  • the integer value output from the output layer (layer 4) is not the target value itself that the neural network 420 should calculate from the real value provided to the input layer, but is proportional to the target value.
  • the scale unit 210 may restore the target value from the output integer value by applying an output scaling factor to the output integer value output from the output layer.
  • the target value may be an integer or a real value.
  • the target value may be expressed in a fixed-point form or in a floating-point form.
  • the structure of the neural network 420 is simply presented in FIG. 5 for convenience of explanation, it may be implemented more complexly than this according to an embodiment. However, from the structure of the neural network 420 shown in FIG. 5 , the more complex structures of the neural network 420 according to another embodiment can be fully understood.
  • Each of the nodes shown in FIG. 5 is configured to output an integer.
  • a multiplier existing inside each node may be configured to perform only integer multiplication. Since the multiplier does not need to perform multiplication between real numbers, its complexity is relatively low.
  • the neural network 420 may be a DNN or n-layer neural network including two or more hidden layers.
  • the neural network 420 may be a DNN including an input layer (Layer 1), two hidden layers (Layer 2 and Layer 3), and an output layer (Layer 4).
  • Layer 1 an input layer
  • Layer 2 and Layer 3 two hidden layers
  • Layer 4 an output layer
  • the neural network 420 is illustrated as including four layers, this is only an example and the neural network 420 may include fewer or more layers, or fewer or more channels. That is, the neural network 420 may include layers of various structures.
  • Each of the layers included in the neural network 420 may include a plurality of channels.
  • a channel may correspond to a plurality of artificial nodes/computation nodes/nodes known as neurons, processing elements (PEs), units, or similar terms.
  • Layer 1 may include two channels (nodes)
  • Layer 2 and Layer 3 may each include three channels.
  • each of the layers included in the neural network 420 may include a variable number of channels (nodes).
  • FIG. 6 shows a method of generating an output activation at each node of the input layer of the neural network shown in FIG. 5 .
  • Activation having a real value may be provided to each node (eg, N11 ) of the input layer (layer 1).
  • the real value may have a floating-point or fixed-point format.
  • Each node of the input layer may convert the input real value into an output activation having an integer value.
  • S I is the input scaling factor given in advance
  • I A is the input activation (real number)
  • q I is the output activation (integer)
  • the output activation q I is generated by approximating to the integer value by removing the decimal part from the value obtained by dividing the input activation I A by the input scaling factor S I given in advance.
  • the operator quantize ( ) is an operator that approximates a real number to an integer close to it.
  • S 1 S I .
  • the superscript attached to each term indicates the layer number '1' of the first layer, which is the input layer.
  • the output of each node of the input layer is an integer.
  • the input scaling factor S I may be provided from a device different from the terminal 200 , for example, a server.
  • FIG. 7 shows a method of generating an output activation at each node of an intermediate layer (hidden layer) of the neural network shown in FIG. 5 .
  • FIG. 7 shows a method of generating output activation at each node of the second layer (layer 2) of the neural network shown in FIG. 5 .
  • the nodes N11 and N12 of the input layer output output activations q I1 1 and q I2 1 .
  • Output activations output from the nodes of the input layer may be input to each node of the second layer (layer 2) that is a downstream layer of the input layer (layer 1) as input activations for the second layer.
  • pre-prepared weights q' w.ab 1 corresponding to each of the respective input activations may be input to each node of the second layer.
  • the output activation q Ia 2 of an arbitrary node (a) in the second layer may be expressed as in [Equation 2].
  • Equation 2 A multiplication operation is performed in Equation 2, and since the multiplication is multiplication between integers, an operation for multiplying two integers is sufficient. This has the advantage of consuming less hardware resources than an operator performing multiplication between real numbers.
  • the multiplication operator only needs to be provided upstream of the summation operator, and does not need to be provided downstream of the summation operator. Only the Right_Shift operator needs to be provided downstream of the summation operator.
  • a denotes an index identifying a node of the second layer
  • b denotes an index identifying a node of a first layer upstream of the second layer
  • a superscript is a layer number indicates That is, the weight assigned to each link of the neural network 420 shown in FIG. 5 may be a value independently provided according to the number of the layer to which the weight is provided, and a source node and a target node of each link.
  • each weight q' w.ab Layer_L may be a value provided to the terminal 200 by a device different from the terminal 200 , for example, a server.
  • both the input and output of each node of the second layer are integers.
  • b 21 shown in FIG. 7 is a bias applied to the node N21 and may have an integer value.
  • FIG. 8 shows an output generation method at each node of the intermediate layer (hidden layer) of the neural network shown in FIG. 5 .
  • FIG. 8 shows a method of generating output activation at each node of the third layer (layer 3) of the neural network 420 shown in FIG. 5 .
  • the 22nd node N22 of the second layer outputs the output activation q I2 2
  • the 23rd node N23 of the second layer outputs the output activation q I3 2 .
  • Output activations output from the nodes of the second layer may be input to each node of the third layer, which is a downstream layer of the second layer, as input activations for the third layer.
  • pre-prepared weights q' w.ab 2 corresponding to each of the respective input activations may be input to each node of the third layer.
  • the 31st node N31 of the third layer outputs an output activation q I1 3 .
  • the output activation q Ia 3 of an arbitrary node (a) of the third layer may be expressed as in [Equation 3].
  • q Ia 3 Right_Shift ⁇ n3 , ( q I1 2 *q' w.a1 2 + q I2 2 *q' w.a2 2 + q I3 2 *q' w.a3 2 + b 31 ) ⁇
  • Equation 3 A multiplication operation is performed in Equation 3, and since the multiplication is multiplication between integers, an operation for multiplying two integers is sufficient.
  • a represents an index for identifying a node of the third layer
  • b represents an index for identifying a node of a second layer upstream of the third layer
  • the superscript is a layer number indicates
  • b 31 shown in FIG. 8 is a bias applied to the node N31 and may have an integer value.
  • FIG. 9 shows an output generation method at each node of the output layer of the neural network shown in FIG. 5 .
  • FIG. 9 shows a method of generating output activation at each node of the fourth layer (output layer) of the neural network 420 shown in FIG. 5 .
  • FIG. 9 a 41 th node N41 among the nodes of the output layer shown in FIG. 5 is shown in FIG. 9 .
  • the 32nd node N32 of the third layer outputs the output activation q I2 3
  • the 33rd node N33 of the third layer outputs the output activation q I3 3 .
  • pre-prepared weights q' w.ab 3 corresponding to each of the respective input activations may be input to each node of the fourth layer.
  • the output activation q Ia 4 of any node of the fourth layer may be expressed as [Equation 4].
  • q Ia 4 Right_Shift ⁇ n4 , ( q I1 3 *q' w.a1 3 + q I2 3 *q' w.a2 3 + q I3 3 *q' w.a3 3 + b 41 ) ⁇
  • Equation 4 A multiplication operation is performed in Equation 4, and since the multiplication is multiplication between integers, an operation for multiplying two integers is sufficient.
  • a represents an index for identifying a node of the fourth layer
  • b represents an index for identifying a node of a third layer upstream of the fourth layer
  • the superscript is a layer number indicates
  • b 41 shown in FIG. 9 is a bias applied to the node N41 and may have an integer value.
  • Equation 2 Any two distinct numbers selected from n2, n3, and n4 shown in Equation 2, Equation 3, and Equation 4 may be different from or the same as each other.
  • a is an index of a specific node of layer L+1
  • b is an index of a specific node of layer L
  • Layer_N is a link from node b of layer L to node a of layer L+1 is the weight assigned to
  • FIG. 10 is a diagram illustrating a method of restoring a target value from an output integer value output from each node of the output layer of the neural network shown in FIG. 5 .
  • the restored value O A restored by the scale unit 210 from the output integer value q O output by the node belonging to the output layer has the same relationship as [Equation 6].
  • S O is a pre-given output layer scale factor.
  • the restored value output by the scale unit may be expressed in a real number of a fixed-point format or a floating-point format.
  • SO may be a value provided to the terminal 200 by a device other than the terminal, for example, a server.
  • the Right_Shift operation performed at each node of the hidden layers and the output layer of the neural network 420 shown in FIG. 5 may all be an n-bit shift.
  • the output values of each node of the neural network 420 shown in FIG. 5 are all n-bit integers, and the values of each weight are also all n-bit integers.
  • 11 shows information provided by the server to the terminal.
  • the server 100 may provide the above-described input layer scaling factor (S I ) and output layer scaling factor (SO ) to the terminal 200 .
  • the server 100 may provide all the above-described weights to the terminal 200 .
  • the server 100 may provide the terminal 200 with an n value used for the n-bit Right-Shift operation.
  • the n value used for the right-shift operation may be independently set for each layer. Accordingly, the server 100 may provide the terminal 200 with n values to be assigned to each layer of the integer neural network provided according to an embodiment of the present invention.
  • the server 100 must be able to generate the above-described data. This method will be described with reference to FIG. 12 .
  • the server 100 may provide the terminal 200 with only the input layer scaling factor ( SI ), the output layer scaling factor (SO ), weights, and n values used for the n-bit Right-Shift operation. there is.
  • the server 100 may have to provide not only the above-mentioned information but also the structure information of the neural network to the terminal 200 .
  • the neural network 410 shown in FIG. 12 has a structure corresponding to the neural network 420 shown in FIG. 5 .
  • the weight w.ab assigned to each link of the learned neural network 410 may be a real value.
  • the real value may be expressed in a fixed-point method or a floating-point method.
  • the neural network 410 illustrated in FIG. 12 includes a total of four layers including an input layer and an output layer. Each layer is assigned a corresponding scaling factor.
  • the value of the scaling factor may be determined as an arbitrary value, but in a preferred embodiment may be determined according to a well-designed method.
  • Patent Publication No. 10-2019-0014900 provides an example of generating a scaling factor assigned to each layer.
  • the scaling factors S 2 , S 3 allocated to the hidden layer do not need to be provided to the terminal 200 , but are used in the process of calculating the respective weights q a Layer_L to be provided to the terminal 200 . can be
  • the weight to be provided by the server 100 to the terminal 200 may be calculated by Equation 7.
  • layer_L represents the L-th layer
  • layer_L+1 represents the L+1-th layer
  • S Layer_L represents the scaling factor given to the L-th layer
  • S Layer_L+1 represents the scaling factor given to the L+1-th layer
  • w.ab Layer_L represents the weight given to the link from node b of the Lth layer to the node a of the L+1th layer
  • q' w.ab layer_L is an n-bit integer, which is a quantized weight obtained from w.ab Layer_L for the server to provide to the terminal.
  • FIG. 13A is a block diagram illustrating a hardware configuration of a server according to an embodiment of the present invention.
  • the server may be referred to as a neural network quantization device.
  • the server 100 includes a processor 110 and a memory 120 .
  • the server 100 shown in FIG. 13A only the components related to the present embodiments are shown. Accordingly, it is apparent to those skilled in the art that other general-purpose components may be further included in the server 100 in addition to the components illustrated in FIG. 13A .
  • the server 100 generates a neural network 410, trains (or learns) the neural network 410, or quantizes a floating-point type neural network 410 into a fixed-point type neural network 420. Or, it corresponds to a computing device having various processing functions, such as functions to retrain the neural network 410 .
  • the server 100 may be implemented with various types of devices such as a personal computer (PC), a server device, and a mobile device.
  • the processor 110 serves to perform an overall function for controlling the server 100 .
  • the processor 110 generally controls the server 100 by executing programs stored in the memory 120 in the server 100 .
  • the processor 110 may be implemented as a central processing unit (CPU), a graphics processing unit (GPU), an application processor (AP), etc. provided in the server 100 , but is not limited thereto.
  • the memory 120 is hardware for storing various types of data processed in the server 100 , and for example, the memory 120 may store data processed by the server 100 and data to be processed. In addition, the memory 120 may store applications to be driven by the server 100 , drivers, and the like.
  • the memory 120 may be a DRAM, but is not limited thereto.
  • the memory 120 may include at least one of a volatile memory and a nonvolatile memory.
  • Non-volatile memory includes ROM (Read Only Memory), PROM (Programmable ROM), EPROM (Electrically Programmable ROM), EEPROM (Electrically Erasable and Programmable ROM), Flash memory, PRAM (Phase-change RAM), MRAM (Magnetic RAM), RRAM (Resistive RAM), FRAM (Ferroelectric RAM), and the like.
  • Volatile memory includes DRAM (Dynamic RAM), SRAM (Static RAM), SDRAM (Synchronous DRAM), PRAM (Phase-change RAM), MRAM (Magnetic RAM), RRAM (Resistive RAM), FeRAM (Ferroelectric RAM), etc. .
  • the memory 1940 is a hard disk drive (HDD), solid state drive (SSD), compact flash (CF), secure digital (SD), micro secure digital (Micro-SD), mini-SD (mini). secure digital), xD (extreme digital), or Memory Stick.
  • HDD hard disk drive
  • SSD solid state drive
  • CF compact flash
  • SD secure digital
  • Micro-SD micro secure digital
  • mini-SD mini-SD
  • secure digital xD (extreme digital), or Memory Stick.
  • the processor 110 may generate the trained neural network 410 by repeatedly training (learning) a given initial neural network.
  • the initial neural network may have floating-point type parameters, for example, parameters of 32-bit floating point precision in order to secure processing accuracy of the neural network.
  • the parameters may include various types of data input/output to the neural network, such as input/output activations, weights, and biases of the neural network. As the neural network iteratively trains, the floating-point parameters of the neural network can be tuned to compute a more accurate output for a given input.
  • Floating point requires a relatively large amount of computation and memory access frequency compared to fixed point.
  • most of the amount of computation required for processing a neural network is a convolution operation that performs computation of various parameters.
  • the processing of the neural network 410 having floating-point type parameters may not be smooth.
  • the floating-point type parameters processed in the neural network 410 are can be quantized.
  • parameter quantization means converting a floating-point type parameter into a fixed-point type parameter having an integer value.
  • the server 100 converts the parameters of the trained neural network 410 into a fixed-point type of predetermined bits in consideration of the processing performance of the device (eg, mobile device, embedded device, etc.) to which the neural network is to be deployed (eg, mobile device, embedded device, etc.) After performing quantization, the server 100 transmits the quantized neural network 420 to the device to be employed.
  • the device to which the neural network 420 is to be employed may be the aforementioned terminal 200 . Specific examples include, but are not limited to, autonomous vehicles, robotics, smart phones, tablet devices, augmented reality (AR) devices, and Internet of Things (IoT) devices that perform voice recognition and image recognition using neural networks.
  • AR augmented reality
  • IoT Internet of Things
  • the processor 110 obtains data of the neural network 410 that is pre-trained using floating points, stored in the memory 120 .
  • the pretrained neural network 410 may be data repeatedly trained with floating-point type parameters. Training of the neural network may be first iteratively trained with training-set data as input, and then iteratively trained again with test-set data, but is not necessarily limited thereto.
  • the training-set data is input data for training a neural network
  • the test set data is input data that does not overlap with the training-set data, and is data for training while measuring the performance of a neural network trained with the training-set data.
  • the processor 110 may analyze the statistical distribution for each channel of the floating-point type parameter values used in each layer included in each of the feature maps and the kernels from the pre-trained neural network data.
  • the processor 110 may determine the scaling factors corresponding to each of the above-described layers based on the analyzed statistical distribution for each layer. For example, the scaling factors may be determined so that the above-described q' w.ab Layer_L value has sufficient resolution in the form of an n bit integer.
  • the memory 120 is, for example, untrained initial neural network data, neural network data generated in the training process, neural network data for which all training has been completed, quantized neural network data, etc. to be processed or processed by the processor 110 .
  • a related data set may be stored, and various programs related to a training algorithm of a neural network, a quantization algorithm, etc. to be executed by the processor 110 may be stored.
  • 13B is a diagram for explaining the quantization of a pre-trained neural network according to an embodiment of the present invention and employing it in a terminal (hardware accelerator).
  • the processor (110 in FIG. 13A) is a floating-point type (eg, 32-bit floating-point type) neural network train Since the pretrained neural network 410 itself may not be efficiently processed in a low-power or low-performance hardware accelerator due to floating-point type parameters, the processor 110 of the server 100 operates the floating-point type neural network 410 ) is quantized into the neural network 420 of a fixed-point type (eg, a fixed-point type of 16 bits or less).
  • a floating-point type eg, 32-bit floating-point type
  • the terminal is dedicated hardware for driving the neural network 420 , and since it is implemented with relatively low power or low performance, it may be implemented more suitable for a fixed-point operation rather than a floating-point operation.
  • the hardware accelerator may correspond to, for example, a neural processing unit (NPU), a tensor processing unit (TPU), a neural engine, etc. which are dedicated modules for driving a neural network, but is not limited thereto.
  • the hardware accelerator for driving the quantized neural network 420 may be implemented in an independent device separate from the server 100 .
  • the present invention is not limited thereto, and the hardware accelerator may be implemented in the same device as the server 100 .
  • the terminal 200 may not implement the quantized neural network 420 as a hardware accelerator, but may be implemented by a CPU and software.
  • FIG. 14 is a diagram illustrating a neural network calculation method in a terminal provided according to a comparative embodiment.
  • each node further includes one arithmetic unit for multiplying integers. Accordingly, the embodiment of FIG. 7 has lower complexity than the embodiment of FIG. 14 .
  • an additional parameter q S 2 provided for the one added operator should be further provided. That is, the number of parameters that the server should provide to the terminal 200 is greater in the embodiment of FIG. 14 than in the embodiment of FIG. 7 .
  • the operation structure in each node according to FIG. 7 has a great advantage compared to the operation structure in each node according to FIG. 14 .
  • the neural network of FIG. 5 having each node structure according to FIG. 7 can also enjoy improved technical effects.
  • the multiplier and the adder used in the embodiment of the present invention may be integer type operators.
  • the present invention is a complex of next-generation intelligent semiconductor technology development (design)-artificial intelligence processor business, a research project supported by the Ministry of Science and ICT and the Information and Communication Planning and Evaluation Institute affiliated with the National Research Foundation of Open Edge Technology Co., Ltd. (the task execution organization). It was developed in the course of carrying out the research task of developing a sensory-based situational prediction type mobile artificial intelligence processor (task unique number 2020001310, task number 2020-0-01310, research period 2020.04.01 ⁇ 2024.12.31).

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)
  • General Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Computational Linguistics (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Artificial Intelligence (AREA)
  • Neurology (AREA)
  • Image Analysis (AREA)

Abstract

Disclosed is a neural network driving method comprising a shifting step of obtaining one set of first values by multiplying one set of weights by corresponding values of one set of input activations, respectively, obtaining a second value by adding the one set of first values to one another, and obtaining an output activation of a first node by right-shifting the second value by n bits. Each of the one set of input activations and the one set of weights corresponds to n-bit integer-type data.

Description

신경망 연산방법 및 신경망 가중치 생성방법Neural network calculation method and neural network weight generation method
본 발명은 컴퓨팅 기술에 관한 것으로서 특히 신경망 내부의 연산구조 및 이를 위해 제공하는 파라미터의 생성방법에 관한 것이다.The present invention relates to computing technology, and more particularly, to an operation structure inside a neural network and a method of generating parameters provided therefor.
대한민국 공개특허 10-2019-0014900의 "신경망의 파라미터들을 양자화하는 방법 및 장치"에는 신경망의 파라미터들을 양자화하는 방법으로서, 미리 훈련된 신경망의 데이터로부터 부동 소수점 타입의 파라미터 값들에 대한 채널 별 통계적 분포를 분석하고, 채널 별 파라미터의 고정 소수점 표현을 결정하고, 바이어스 및 채널 별 가중치의 프랙션 길이들을 결정하고, 결정된 프랙션 길이들의 바이어스 및 채널 별 가중치를 갖는 고정 소수점 타입의 양자화된 신경망을 생성하는 기술이 공개되어 있다. 상기 공개특허에 따르면 도 1, 도 13a, 및 도 13b와 같은 내용이 제시되어 있다.In Korean Patent Laid-Open Publication No. 10-2019-0014900, "Method and apparatus for quantizing parameters of a neural network," as a method for quantizing parameters of a neural network, statistical distribution for each channel of floating-point type parameter values from data of a pre-trained neural network is obtained. A technique for analyzing, determining a fixed-point representation of a parameter per channel, determining fraction lengths of bias and per-channel weight, and generating a fixed-point type quantized neural network with bias and per-channel weight of the determined fraction lengths this is disclosed. According to the above publication, the same contents as in FIGS. 1, 13A, and 13B are presented.
도 1은 일 실시예에 따른 신경망에서 수행되는 연산을 설명하기 위한 도면이다. 도 1을 참조하면, 신경망(2)은 입력층, 히든층들 및 출력층을 포함하는 구조를 가지며, 수신되는 입력 데이터(I1 및 I2)를 기초로 연산을 수행하고, 수행 결과를 기초로 출력 데이터(O1 및 O2)를 생성할 수 있다.1 is a diagram for explaining an operation performed in a neural network according to an embodiment. Referring to FIG. 1 , the neural network 2 has a structure including an input layer, hidden layers, and an output layer, performs an operation based on received input data I1 and I2 , and outputs data based on the result of the execution. (O1 and O2) can be formed.
신경망(2)에 포함된 층들 각각은 복수의 채널들을 포함할 수 있다. 채널은 뉴런(neuron), 프로세싱 엘리먼트(Processing element, PE), 유닛(unit) 또는 이와 유사한 용어들로 알려진, 복수의 인공 노드(artificial node)들에 해당될 수 있다. 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 a neuron, a processing element (PE), a unit, or similar terms.
신경망(2)의 층들 각각에 포함된 채널들은 서로 연결되어 데이터를 처리할 수 있다. 예를 들어, 하나의 채널은 다른 채널들로부터 데이터를 수신하여 연산할 수 있고, 연산 결과를 또 다른 채널들로 출력할 수 있다.Channels included in each of the layers of the neural network 2 may be connected to each other to process data. For example, one channel may perform an operation by receiving data from other channels, and may output an operation result to other channels.
층(layer)들 각각의 입력 및 출력 각각은 입력 액티베이션 및 출력 액티베이션이라고 지칭될 수 있다. 즉, 액티베이션은 한 채널의 출력임과 동시에, 다음 층에 포함된 채널들의 입력에 해당되는 파라미터일 수 있다. 한편, 채널들 각각은 이전 층에 포함된 채널들로부터 수신된 액티베이션들 및 가중치들에 기초하여 자신의 액티베이션을 결정할 수 있다. 가중치는 각 층에서의 출력 액티베이션을 계산하기 위해 이용되는 파라미터로서, 층들 간의 연결관계에 할당되는 값일 수 있다.The input and output, respectively, of each of the layers 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 and weights received from channels included in the previous layer. The weight is a parameter used to calculate output activation in each layer, and may be a value assigned to a connection relationship between layers.
일반적으로 하나의 입력 데이터에 대한 액티베이션은 좌표(이미지의 경우 x, y로 2차원) 하나하나에 대해서 c개의 어떤 값을 가질 수 있으며 이 c개의 값에 대한 축을 채널축이라고 표현할 수 있다. 다시 말해 하나의 입력은 (좌표*채널) 개의 데이터로 구성될 수 있다.In general, activation of one input data can have c certain values for each coordinate (two-dimensional in x and y in the case of an image), and the axis for these c values can be expressed as a channel axis. In other words, one input may be composed of (coordinates*channel) data.
GPU 등에서는 병렬 처리의 효율성을 높이기 위하여 여러 개의 입력데이터를 묶어서 한 번에 처리하므로 일반적으로 이미지 처리에 대한 액티베이션은 (batch, x, y, 채널) 이렇게 4개의 디멘젼(dimension)으로 구성될 수 있다. 여기서 배치(batch)는 0번 입력, 1번 입력, 2번 입력 등을 나타내는 차원을 의미할 수 있다.In order to increase the efficiency of parallel processing in GPUs, etc., several input data are bundled and processed at once. In general, activation for image processing can be composed of four dimensions such as (batch, x, y, channel). . Here, a batch may mean a dimension representing input 0, input 1, input 2, and the like.
채널들 각각은 입력을 수신하여 출력 액티베이션을 출력하는 연산 유닛(computational unit) 또는 프로세싱 엘리먼트(processing element)에 의해 처리될 수 있고, 채널들 각각의 입력-출력은 매핑될 수 있다. 예를 들어, σ는 액티베이션 함수(activation function)이고, wi jk는 (i-1) 번째 층에 포함된 k 번째 채널로부터 i 번째 층에 포함된 j번째 채널로의 가중치이며, bi j는 i 번째 층에 포함된 j 번째 채널의 바이어스(bias)이고, ai j는 i 번째 층의 j 번째 채널의 액티베이션이라고 할 때, 액티베이션 ai j는 ai j= σ ( SUM k (wi jk * ai-1 k ) + bi j )로 주어질 수 있다.Each of the channels may be processed by a computational unit or processing element that receives an input and outputs an output activation, and an input-output of each of the channels may be mapped. For example, σ is an activation function, w i jk 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, b i j is If it is the bias of the j-th channel included in the i-th layer, and a i j is the activation of the j-th channel in the i-th layer, activation a i j is a i j = σ ( SUM k (w i jk ) * a i-1 k ) + b i j ).
도 1에 도시된 바와 같이, 2번째 층(Layer 2)의 첫 번째 채널(CH 1)의 액티베이션은 a2 1로 표현될 수 있다. 또한, a2 1은 수학식 1에 따라 a2 1= σ (w2 1,1 * a1 1 + w2 1,2 * a1 2 + b2 1 )의 값을 가질 수 있다. 다만, 앞서 설명한 수학식 1은 신경망(2)에서 데이터를 처리하기 위해 이용되는 액티베이션 및 가중치를 설명하기 위한 예시일 뿐, 이에 제한되지 않는다. 액티베이션은 이전층으로부터 수신된 액티베이션들의 합(sum)에 액티베이션 함수를 적용한 값을 Rectified Linear Unit (ReLU)을 통과시킴으로써 획득된 값일 수 있다.1 , activation of the first channel CH 1 of the second layer Layer 2 may be expressed as a 2 1 . Also, according to Equation 1, a 2 1 may have a value of a 2 1 = σ (w 2 1,1 * a 1 1 + w 2 1,2 * a 1 2 + b 2 1 ). However, Equation 1 described above is only an example for explaining the activation and weight used to process data in the neural network 2 , and is not limited thereto. Activation may be a value obtained by passing a value obtained by applying an activation function to the sum of activations received from the previous layer through a Rectified Linear Unit (ReLU).
앞서 설명한 것과 같이, 신경망(2)에서는 수많은 데이터 집합들이 상호 연결된 복수의 채널들 간에 교환되고, 층을 지나면서 수많은 연산 과정을 거친다. 따라서, 복잡한 입력 데이터를 처리하는데 필요한 연산량을 감소시키면서도 정확도 손실을 최소화할 수 있는 기술이 요구된다.As described above, in the neural network 2, numerous data sets are exchanged between a plurality of interconnected channels and undergo numerous computational processes while passing through layers. Accordingly, there is a need for a technique capable of minimizing the loss of accuracy while reducing the amount of computation required to process complex input data.
상술한 선행기술에서 제시한 신경망 양자화 장치는 신경망을 생성하거나, 신경망을 훈련(train)(또는 학습(learn))하거나, 부동 소수점 타입의 신경망을 고정 소수점 타입의 신경망으로 양자화하거나, 또는 신경망을 재훈련(retrain)하는 기능들과 같은 다양한 프로세싱 기능들을 수행한다. 구체적으로는 주어진 초기 신경망을 반복적으로 훈련(학습)시킴으로써, 훈련된 신경망을 생성할 수 있다. 이때, 초기 신경망은 신경망의 처리 정확도 확보 차원에서 부동 소수점 타입의 파라미터들을 가질 수 있다. 이때, 부동 소수점은 고정 소수점에 비해 상대적으로 많은 연산량과 많은 메모리 액세스 빈도가 요구된다. 따라서, 비교적 처리 성능이 낮은 모바일 디바이스, 임베디드(embedded) 디바이스 등에서는 부동 소수점 타입의 파라미터들을 갖는 신경망의 처리가 원활하지 않을 수 있다. 결국, 이와 같은 디바이스들에서 연산량을 감소시키면서 허용 가능한 정확도 손실 내에서 신경망을 구동시키기 위해서는, 상기 부동 소수점 타입의 파라미터들은 양자화되는 것이 바람직하다. 여기서, 파라미터 양자화는, 부동 소수점 타입의 파라미터를, 고정 소수점 타입의 파라미터로 변환하는 것을 의미한다. 따라서 상기 신경망 양자화 장치는 훈련된 신경망의 파라미터들을 소정 비트들의 고정 소수점 타입으로 변환하는 양자화를 수행하고, 양자화된 신경망을 채용될 디바이스에 전달한다. The neural network quantization apparatus proposed in the above-mentioned prior art generates a neural network, trains (or learns) a neural network, quantizes a floating-point type neural network into a fixed-point type neural network, or regenerates a neural network. It performs various processing functions, such as functions to train (retrain). Specifically, a trained neural network can be generated by repeatedly training (learning) a given initial neural network. In this case, the initial neural network may have floating-point type parameters in order to secure processing accuracy of the neural network. In this case, the floating point requires a relatively large amount of computation and a large memory access frequency compared to the fixed point. Accordingly, processing of a neural network having floating-point type parameters may not be smooth in a mobile device, an embedded device, or the like, which has relatively low processing performance. After all, in order to drive the neural network within an acceptable loss of accuracy while reducing the amount of computation in such devices, the floating-point type parameters are preferably quantized. Here, parameter quantization means converting a floating-point type parameter into a fixed-point type parameter. Accordingly, the neural network quantization apparatus performs quantization by converting parameters of a trained neural network into a fixed-point type of predetermined bits, and transmits the quantized neural network to a device to be employed.
상술한 선행기술은 부동 소수점 타입 대신 고정 소수점 타입의 계산을 이용한다는 점에서 이점이 있다. 그러나 여전히 신경망의 각 연산노드 내부의 연산구조의 개량에 관한 접근은 이루어지지 않고 있다. The prior art described above is advantageous in that it uses fixed-point type calculations instead of floating-point types. However, there is still no approach to improving the computational structure inside each computational node of the neural network.
각 연산구조 내부의 연산구조를 개량함으로써 하드웨어 가속기의 성능을 향상시키거나 효율을 높일 수 있을 것이다. By improving the arithmetic structure inside each arithmetic structure, the performance or efficiency of the hardware accelerator may be improved.
본 발명에서는 신경망을 처리하는 컴퓨팅 장치의 하드웨어 복잡도를 감소시키거나, 처리속도를 증가시키거나, 또는 자원의 활용도를 향상시킬 수 있는 기술을 제공하고자 한다.An object of the present invention is to provide a technique capable of reducing hardware complexity of a computing device processing a neural network, increasing processing speed, or improving resource utilization.
구체적으로, 신경망을 하드웨어로 구현하는 경우에 있어서, 신경망 내의 각 연산노드의 구조의 복잡도를 감소시키는 기술을 제공하고자 한다.Specifically, in the case of implementing a neural network in hardware, it is intended to provide a technique for reducing the complexity of the structure of each computation node in the neural network.
그리고 신경망을 소프트웨어로 구현하는 경우에 있어서, 신경망 내의 각 연산노드에서의 연산 알고리즘을 단순화하는 기술을 제공하고자 한다.And, in the case of implementing the neural network as software, it is intended to provide a technique for simplifying the computation algorithm in each computation node in the neural network.
또한, 이러한 기술에 수반하는 것으로서, 연산에 필요한 가중치 파라미터를 정의하고 산출하는 기술을 제공하고자 한다.In addition, as an accompanying technique, it is intended to provide a technique for defining and calculating a weight parameter required for calculation.
일반적으로 신경망을 inference 하는 과정에서는 도 2와 같은 부동 소수점(floating point) 기반의 연산들이 주를 이루고 있다. 도 2에서 IA는 입력 액티베이션(Input activation), OA는 출력 액티베이션(output activation), w는 가중치(weight) 파라미터를 의미한다.In general, in the process of inference of a neural network, floating point-based operations as shown in FIG. 2 are predominant. In FIG. 2 , I A denotes an input activation, O A denotes an output activation, and w denotes a weight parameter.
하지만 부동 소수점 연산기는 정수(integer) 연산기에 비해 복잡하므로 실제 부동 소수점 연산을 통해 신경망 가속기를 만들게 될 경우 하드웨어 사이즈가 커지는 문제가 있다.However, since the floating-point operator is more complicated than the integer operator, there is a problem in that the hardware size increases when a neural network accelerator is made through actual floating-point operation.
이런 문제를 완화하기 위해 입력 액티베이션, 출력 액티베이션, 및 가중치 등을 고정 소수점(fixed point) 형태의 정수로 변환하고, 정수 연산기를 통해 연산을 처리하도록 하드웨어 가속기를 구현할 수 있다.To alleviate this problem, a hardware accelerator may be implemented to convert an input activation, an output activation, and a weight into integers in a fixed point form and process the operation through an integer operator.
고정 소수점 연산을 사용하는 경우 IA, OA, w를 아래 수식 및 도 3a와 같이 정의할 수 있다. When using a fixed-point operation, I A , O A , w may be defined as shown in the following equation and FIG. 3A .
[수학식][Equation]
Figure PCTKR2021014367-appb-I000001
Figure PCTKR2021014367-appb-I000001
Figure PCTKR2021014367-appb-I000002
Figure PCTKR2021014367-appb-I000002
Figure PCTKR2021014367-appb-I000003
Figure PCTKR2021014367-appb-I000003
q is n-bit integerq is n-bit integer
그 후, q 값이 n bit integer 형태에서 충분한 해상력을 가지도록 스케일(Scale) 값을 결정하고, /scale, quantize 과정을 통해 부동 소수점 값을 정수 형태의 고정 소수점 형식으로 변환할 수 있다. Thereafter, the scale value is determined so that the q value has sufficient resolution in the form of an n-bit integer, and the floating-point value can be converted into the fixed-point format of the integer form through the /scale and quantize process.
그 다음, 도 3b와 같이 고정 소수점 값 q 를 이용해서 연산을 진행하게 된다. Next, as shown in FIG. 3B , an operation is performed using the fixed-point value q.
일반적으로 SI, Sw, SO 값은 한 레이어(per layer) 혹은 한 액티베이션의 특정 채널(per channel) 내에서 공통으로 사용되는 값으로, qw의 경우 같은 레이어 내에서도 가중치 파라미터 각각이 다른 값을 가질 수 있으나 qS의 경우 레이어 내에서 혹은 한 액티베이션의 특정 채널 내에서 공통으로 사용된다.In general, S I , S w , and S O values are commonly used values within one layer or a specific channel of one activation . , but in the case of q S , it is commonly used within a layer or within a specific channel of one activation.
본 발명에서는, 도 2, 도 3a, 및 도 3b에 나타낸 것과 비슷한 연산 효과를 보이면서도 더 간단한 하드웨어를 만들기 위한 방법으로 도 4와 같은 형태의 고정 소수점 기반 양자화 연산(quantized arithmetic) 방법을 제공한다. 이 경우 각 곱셈 하나당 곱셈기(multiplier) 하나씩을 줄일 수 있기 때문에 더 작은 사이즈의 하드웨어를 만들 수 있다는 장점이 있다.In the present invention, a fixed-point-based quantized arithmetic method of the form shown in FIG. 4 is provided as a method for making simpler hardware while exhibiting an operation effect similar to that shown in FIGS. 2, 3A, and 3B. In this case, since one multiplier can be reduced for each multiplication, there is an advantage in that hardware of a smaller size can be made.
본 발명은 위와 같은 양자화 연산을 위한 가중치 파라미터 q'w를 만들어 내는 양자화 알고리즘을 포함한다. 이 알고리즘은 가중치에 SI/SO을 미리 곱해준 뒤 고정 소수점 정수로 변환하는 알고리즘이다. The present invention includes a quantization algorithm for generating a weight parameter q' w for the above quantization operation. This algorithm is an algorithm that premultiplies the weight with S I /S O and then converts it to a fixed-point integer.
본 발명의 일 관점에 따라 입력층, 중간층부, 및 출력층을 포함하는 정수형 신경망의 특정층의 동작을 실행하는 데이터 연산부 및 상기 데이터 연산부에게 연산용 데이터를 제공하는 내부 메모리를 포함하는 컴퓨팅 장치를 제공할 수 있다. 이때, 상기 특정층이 상기 중간층부 또는 상기 출력층에 속한 제1층인 경우, 상기 제1층에 포함된 제1노드는, 상기 제1노드에 입력되는 한 세트의 입력 액티베이션들과 상기 한 세트의 액티베이션들에 대응하는 한 세트의 가중치들을 각각 곱하는 한 세트의 곱셈기들; 상기 한 세트의 곱셈기의 출력들을 서로 더하는 덧셈기; 및 상기 제1노드의 출력 액티베이션을 생성하기 위하여 상기 덧셈기의 출력을 변환하여 시프트부;를 포함할 수 있다. 그리고 상기 한 세트의 입력 액티베이션들 및 상기 한 세트의 가중치들 각각은 n비트의 정수형 데이터이며, 상기 시프트부는 상기 덧셈기의 출력을 n비트 우측-시프트하도록 되어 있을 수 있다.According to one aspect of the present invention, there is provided a computing device comprising a data operation unit that executes an operation of a specific layer of an integer type neural network including an input layer, an intermediate layer, and an output layer, and an internal memory that provides data for operation to the data operation unit can do. In this case, when the specific layer is the first layer belonging to the intermediate layer part or the output layer, the first node included in the first layer includes a set of input activations input to the first node and a set of activations. a set of multipliers each multiplying a set of weights corresponding to s; an adder for adding the outputs of the set of multipliers to each other; and a shift unit converting the output of the adder to generate output activation of the first node. In addition, each of the set of input activations and the set of weights may be n-bit integer data, and the shift unit may be configured to right-shift the output of the adder by n bits.
이때, 상기 특정층이 상기 입력층인 경우, 상기 입력층에 포함된 제2노드는, 상기 제2노드에 입력되는 실수값을 갖는 액티베이션을 소정의 입력 스케일링 팩터를 이용하여 정수값을 갖는 액티베이션으로 변환하도록 되어 있을 수 있다.In this case, when the specific layer is the input layer, the second node included in the input layer converts activation having a real value input to the second node into activation having an integer value using a predetermined input scaling factor. may be adapted to be converted.
이때, 상기 컴퓨팅장치는 소정의 출력 스케일링 팩터를 이용하여 상기 출력층이 출력한 액티베이션을 변환하여 출력하는 스케일링부를 더 포함할 수 있다.In this case, the computing device may further include a scaling unit that converts and outputs the activation output by the output layer using a predetermined output scaling factor.
이때, 상기 입력 스케일링 팩터, 상기 출력 스케일링 팩터, 및 상기 한 세트의 가중치들은 상기 컴퓨팅 장치가 다른 컴퓨팅 장치로부터 제공받은 것일 수 있다. 그리고 상기 다른 컴퓨팅장치는, 상기 정수형 신경망에 대응하는 구조를 갖는 원-신경망에 관한 정보를 이용하도록 되어 있으며, 상기 원-신경망의 입력층에 할당된 상기 입력 스케일링 팩터를 생성하도록 되어 있고, 상기 원-신경망의 출력층에 할당된 상기 출력 스케일링 팩터를 생성하도록 되어 있고, 상기 원-신경망에서 상기 입력층과 상기 출력층 사이에 정의된 중간층들 각각에 할당된 스케일링 팩터들을 생성하도록 되어 있고, 상기 원-신경망에서 상기 제1노드에 대응하는 노드를 포함하는 제L+1층의 상류에 직결된 제L층에 할당된 제L 스케일링 팩터를 상기 제L+1층에 할당된 제L+1 스케일링 팩터로 나누어 제1값을 산출하고, 상기 제L층의 인덱스 b를 갖는 노드로부터 상기 제L+1층의 인덱스 a를 갖는 노드에 연결된 링크(linkab Layer_L)에 할당된 가중치(w.ab Layer_L)에 상기 제1값을 곱하여 제2값을 산출하고, 상기 제2값에 2n을 곱하여 제3값을 산출하고, 상기 제3값을 정수값으로 근사화하여 제4값을 생성하도록 되어 있고, 상기 제4값은, 상기 가중치(w.ab Layer_L)에 대응하는 상기 정수형 신경망의 가중치(q'w.ab layer_L)인 것을 특징으로 할 수 있다. In this case, the input scaling factor, the output scaling factor, and the one set of weights may be provided by the computing device from another computing device. and the other computing device is configured to use information about a neural network having a structure corresponding to the integer neural network, and to generate the input scaling factor assigned to an input layer of the original neural network, - generate the output scaling factor assigned to an output layer of a neural network, and generate scaling factors assigned to each of the intermediate layers defined between the input layer and the output layer in the original-neural network, dividing the Lth scaling factor assigned to the Lth layer directly upstream of the L+1th layer including the node corresponding to the first node by the L+1th scaling factor assigned to the L+1th layer in A first value is calculated, and the weight (w.ab Layer_L ) assigned to the link (link ab Layer_L ) connected from the node having the index b of the Lth layer to the node having the index a of the L+1th layer is added to the multiply the first value to calculate a second value, multiply the second value by 2 n to obtain a third value, and approximate the third value to an integer value to generate a fourth value, wherein the fourth value is The value may be a weight (q' w.ab layer_L ) of the integer neural network corresponding to the weight ( w.ab Layer_L ) .
본 발명의 일 관점에 따라 처리부 및 저장부를 포함하는 단말기가, 입력층, 중간층부, 및 출력층을 포함하는 정수형 신경망의 상기 중간층부 또는 상기 출력층에 포함된 제1노드의 출력 액티베이션을 생성하는 신경망 구동방법을 제공할 수 있다. 이때, 상기 신경망 구동방법은, 상기 처리부가, 한 세트의 입력 액티베이션들을 상기 저장부로부터 획득하고, 그리고 상기 한 세트의 입력 액티베이션들에 대응하며 한 세트의 가중치들을 상기 저장부로부터 획득하는 단계; 상기 처리부가, 상기 한 세트의 가중치들과 상기 한 세트의 입력 액티베이션들의 서로 대응하는 값들을 각각 서로 곱하여 한 세트의 제1값들을 산출하는 곱셈단계; 상기 처리부가, 상기 한 세트의 제1값들을 서로 더하여 제2값을 산출하는 덧셈단계; 및 상기 처리부가, 상기 제2값을 n비트 우측-시프트함으로써 상기 제1노드의 출력 액티베이션을 산출하는 시프팅 단계;를 포함할 수 있다. 이때, 상기 한 세트의 입력 액티베이션들 및 상기 한 세트의 가중치들 각각은 n비트의 정수형 데이터일 수 있다. According to an aspect of the present invention, a terminal including a processing unit and a storage unit drives a neural network to generate an output activation of the first node included in the intermediate layer or the output layer of an integer neural network including an input layer, an intermediate layer, and an output layer method can be provided. In this case, the neural network driving method may include: obtaining, by the processing unit, a set of input activations from the storage unit, and acquiring a set of weights corresponding to the set of input activations from the storage unit; a multiplication step in which the processing unit multiplies the one set of weights and the values corresponding to each other of the one set of input activations to calculate a set of first values; an adding step in which the processing unit adds the set of first values to each other to calculate a second value; and a shifting step in which the processing unit calculates the output activation of the first node by right-shifting the second value by n bits. In this case, each of the set of input activations and the set of weights may be n-bit integer data.
이때, 상기 신경망 구동방법은, 상기 처리부가, 상기 입력층에 속한 제2노드에 입력되는 실수값을 갖는 액티베이션을 소정의 입력 스케일링 팩터를 이용하여 정수값을 갖는 액티베이션으로 변환하는 단계; 및 상기 처리부가, 상기 출력층이 출력한 액티베이션을 소정의 출력 스케일링 팩터를 이용하여 변환하는 단계;를 더 포함할 수 있다. In this case, the method of driving the neural network includes: converting, by the processor, an activation having a real value input to a second node belonging to the input layer into an activation having an integer value using a predetermined input scaling factor; and converting, by the processing unit, the activation output from the output layer using a predetermined output scaling factor.
이때, 상기 입력 스케일링 팩터, 상기 출력 스케일링 팩터, 및 상기 한 세트의 가중치들은 상기 단말기가 다른 컴퓨팅 장치로부터 제공받은 것일 수 있다. 상기 다른 컴퓨팅장치는, 상기 정수형 신경망에 대응하는 구조를 갖는 원-신경망에 관한 정보를 이용하도록 되어 있으며, 상기 원-신경망의 입력층에 할당된 상기 입력 스케일링 팩터를 생성하도록 되어 있고, 상기 원-신경망의 출력층에 할당된 상기 출력 스케일링 팩터를 생성하도록 되어 있고, 상기 원-신경망에서 상기 입력층과 상기 출력층 사이에 정의된 중간층들 각각에 할당된 스케일링 팩터들을 생성하도록 되어 있고, 상기 원-신경망에서 상기 제1노드에 대응하는 노드를 포함하는 제L+1층의 상류에 직결된 제L층에 할당된 제L 스케일링 팩터를 상기 제L+1층에 할당된 제L+1 스케일링 팩터로 나누어 제1값을 산출하고, 상기 제L층의 인덱스 b를 갖는 노드로부터 상기 제L+1층의 인덱스 a를 갖는 노드에 연결된 링크(linkab Layer_L)에 할당된 가중치(w.ab Layer_L)에 상기 제1값을 곱하여 제2값을 산출하고, 상기 제2값에 2n을 곱하여 제3값을 산출하고, 상기 제3값을 정수값으로 근사화하여 제4값을 생성하도록 되어 있을 수 있다. 상기 제4값은, 상기 가중치(w.ab Layer_L)에 대응하는 상기 정수형 신경망의 가중치(q'w.ab layer_L)인 것을 특징으로 할 수 있다.In this case, the input scaling factor, the output scaling factor, and the set of weights may be provided by the terminal from another computing device. The other computing device is configured to use information about a one-neural network having a structure corresponding to the integer neural network, and to generate the input scaling factor assigned to an input layer of the original-neural network, generate the output scaling factor assigned to an output layer of a neural network, and generate scaling factors assigned to each of the intermediate layers defined between the input layer and the output layer in the original neural network, wherein in the original neural network The L-th scaling factor allocated to the L-th layer directly upstream of the L+1-th layer including the node corresponding to the first node is divided by the L+1-th scaling factor allocated to the L+1-th layer to obtain a A value of 1 is calculated, and the weight (w.ab Layer_L ) assigned to the link (link ab Layer_L ) connected from the node having the index b of the Lth layer to the node having the index a of the L+1th layer is added to the weight value w.ab Layer_L . A second value is calculated by multiplying the value by 1, a third value is calculated by multiplying the second value by 2 n , and a fourth value is generated by approximating the third value to an integer value. The fourth value may be a weight (q' w.ab layer_L ) of the integer neural network corresponding to the weight ( w.ab Layer_L ) .
본 발명의 일 관점에 따른 정수형 신경망 정보처리방법을 제공할 수 있다. 상기 정수형 신경망 정보처리방법은, 서버가, 입력층, 중간층부, 및 출력층를 갖는 신경망의 상기 입력층에 할당된 입력 스케일링 팩터를 생성하고, 상기 출력층에 할당된 출력 스케일링 팩터를 생성하고, 그리고 상기 중간층부의 각 층에 할당된 스케일링 팩터들을 생성하는 단계; 및 상기 서버가, 상기 중간층부 또는 출력층에 포함된 제1노드를 포함하는 제L+1층의 상류에 직결된 제L층에 할당된 제L 스케일링 팩터를 상기 제L+1층에 할당된 제L+1 스케일링 팩터로 나누어 제1값을 산출하고, 상기 제L층의 인덱스 b를 갖는 노드로부터 상기 제L+1층의 인덱스 a를 갖는 노드에 연결된 링크(linkab Layer_L)에 할당된 가중치(w.ab Layer_L)에 상기 제1값을 곱하여 제2값을 산출하고, 상기 제2값에 2n을 곱하여 제3값을 산출하고, 상기 제3값을 정수값으로 근사화하여 제4값을 생성하는 단계;를 포함할 수 있다. 이때, 상기 제4값은, 상기 가중치(w.ab Layer_L)에 대응하는 정수형 신경망의 가중치(q'w.ab layer_L)인 것을 특징으로 할 수 있다.It is possible to provide an integer neural network information processing method according to an aspect of the present invention. In the integer neural network information processing method, a server generates an input scaling factor assigned to the input layer of a neural network having an input layer, an intermediate layer part, and an output layer, and generates an output scaling factor assigned to the output layer, and the intermediate layer generating scaling factors assigned to each layer of negative; and the server assigns the Lth scaling factor assigned to the Lth layer directly upstream of the L+1th layer including the first node included in the intermediate layer unit or the output layer to the L+1th layer. A weight assigned to a link (link ab Layer_L ) connected from a node having an index b of the L-th layer to a node having an index a of the L+1 layer to calculate a first value by dividing by the L+1 scaling factor ( w .ab Layer_L ) is multiplied by the first value to calculate a second value, the second value is multiplied by 2 n to calculate a third value, and the third value is approximated to an integer value to generate a fourth value may include; In this case, the fourth value may be a weight (q' w.ab layer_L ) of the integer neural network corresponding to the weight (w .ab Layer_L ).
이때, 상기 정수형 신경망 정보처리방법은, 상기 서버가, 상기 입력 스케일링 팩터, 상기 출력 스케일링 팩터, 및 상기 정수형 신경망의 가중치를, 상기 정수형 신경망의 동작을 실행하는 컴퓨팅 장치에게 제공하는 단계를 더 포함할 수 있다.In this case, the integer neural network information processing method may further include the step of providing, by the server, the input scaling factor, the output scaling factor, and a weight of the integer neural network to a computing device executing the operation of the integer neural network. can
본 발명에 따르면 신경망을 처리하는 컴퓨팅 장치의 하드웨어 복잡도를 감소시키거나, 처리속도를 증가시키거나, 또는 자원의 활용도를 향상시킬 수 있는 기술을 제공할 수 있다.According to the present invention, it is possible to provide a technology capable of reducing hardware complexity of a computing device processing a neural network, increasing processing speed, or improving resource utilization.
구체적으로, 신경망을 하드웨어로 구현하는 경우에 있어서, 신경망 내의 각 연산노드의 구조의 복잡도를 감소시키는 기술을 제공할 수 있다.Specifically, when the neural network is implemented as hardware, it is possible to provide a technique for reducing the complexity of the structure of each computation node in the neural network.
그리고 신경망을 소프트웨어로 구현하는 경우에 있어서, 신경망 내의 각 연산노드에서의 연산 알고리즘을 단순화하는 기술을 제공할 수 있다.In addition, when the neural network is implemented as software, it is possible to provide a technique for simplifying the computation algorithm in each computation node in the neural network.
또한, 이러한 기술에 수반하는 것으로서, 연산에 필요한 가중치 파라미터를 정의하고 산출하는 기술을 제공할 수 있다.In addition, it is possible to provide a technique for defining and calculating a weight parameter required for calculation as accompanying such a technique.
도 1은 일 실시예에 따른 신경망에서 수행되는 연산을 설명하기 위한 도면이다.1 is a diagram for explaining an operation performed in a neural network according to an embodiment.
도 2는 본 발명의 창작과정을 설명하기 위해 제시한 개념도이다.2 is a conceptual diagram presented to explain the creative process of the present invention.
도 3a 및 도 3b는 본 발명의 창작과정을 설명하기 위해 제시한 개념도이다.3A and 3B are conceptual diagrams presented to explain the creative process of the present invention.
도 4는 본 발명의 창작과정을 설명하기 위해 제시한 개념도이다.4 is a conceptual diagram presented to explain the creative process of the present invention.
도 5는 본 발명의 일 실시예에 따라 제공되는 단말기에서 실행되는 신경망의 구조의 예를 도시한 것이다. 5 illustrates an example of the structure of a neural network executed in a terminal provided according to an embodiment of the present invention.
도 6은 도 5에 나타낸 신경망의 입력층의 각 노드에서의 출력 액티베이션의 생성방법을 나타낸 것이다. FIG. 6 shows a method of generating an output activation at each node of the input layer of the neural network shown in FIG. 5 .
도 7은 도 5에 나타낸 신경망의 중간층(히든층)의 각 노드에서의 출력 액티베이션의 생성방법을 나타낸 것이다.FIG. 7 shows a method of generating an output activation at each node of an intermediate layer (hidden layer) of the neural network shown in FIG. 5 .
도 8은 도 5에 나타낸 신경망의 중간층(히든층)의 각 노드에서의 출력생성방법을 나타낸 것이다.FIG. 8 shows an output generation method at each node of the intermediate layer (hidden layer) of the neural network shown in FIG. 5 .
도 9는 도 5에 나타낸 신경망의 출력층의 각 노드에서의 출력생성방법을 나타낸 것이다.FIG. 9 shows an output generation method at each node of the output layer of the neural network shown in FIG. 5 .
도 10은 도 5에 나타낸 신경망의 출력층의 각 노드에서 출력한 출력 정수값으로부터 목표값을 복원하는 방법을 나타낸 것이다.10 is a diagram illustrating a method of restoring a target value from an output integer value output from each node of the output layer of the neural network shown in FIG. 5 .
도 11은 서버에서 상기 단말기에게 제공하는 정보를 나타낸 것이다.11 shows information provided by the server to the terminal.
도 12는 서버에서 학습 완료한 신경망의 구조를 나타낸다. 도 12에 나타낸 신경망은 도 5에 나타낸 신경망에 대응하는 구조를 갖는다.12 shows the structure of a neural network that has been trained by the server. The neural network shown in FIG. 12 has a structure corresponding to the neural network shown in FIG. 5 .
도 13a는 본 발명의 일 실시예에 따른 서버의 하드웨어 구성을 도시한 블록도이다.13A is a block diagram illustrating a hardware configuration of a server according to an embodiment of the present invention.
도 13b는 본 발명의 일 실시예에 따른 미리 훈련된 신경망을 양자화하여 단말기(하드웨어 가속기)에 채용하는 것을 설명하기 위한 도면이다.13B is a diagram for explaining the quantization of a pre-trained neural network according to an embodiment of the present invention and employing it in a terminal (hardware accelerator).
도 14는 비교 실시예에 따라 제공되는 단말기 내에서의 신경망 연산방법을 나타낸 것이다.14 is a diagram illustrating a neural network calculation method in a terminal provided according to a comparative embodiment.
이하, 본 발명의 실시예를 첨부한 도면을 참고하여 설명한다. 그러나 본 발명은 본 명세서에서 설명하는 실시예에 한정되지 않으며 여러 가지 다른 형태로 구현될 수 있다. 본 명세서에서 사용되는 용어는 실시예의 이해를 돕기 위한 것이며, 본 발명의 범위를 한정하고자 의도된 것이 아니다. 또한, 이하에서 사용되는 단수 형태들은 문구들이 이와 명백히 반대의 의미를 나타내지 않는 한 복수 형태들도 포함한다.Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, the present invention is not limited to the embodiments described herein and may be implemented in various other forms. The terminology used herein is for the purpose of helping the understanding of the embodiments, and is not intended to limit the scope of the present invention. Also, singular forms used hereinafter include plural forms unless the phrases clearly indicate the opposite.
도 5는 본 발명의 일 실시예에 따라 제공되는 단말기에서 실행되는 신경망의 구조의 예를 도시한 것이다. 5 illustrates an example of the structure of a neural network executed in a terminal provided according to an embodiment of the present invention.
상기 신경망(420)은 상기 단말기(200) 내에서 하드웨어로 구현될 수도 있고 또는 소프트웨어로 구현될 수도 있다.The neural network 420 may be implemented as hardware or software within the terminal 200 .
신경망(420)은 복수 개의 층들(layer 1, layer 2, layer 3, layer 4)을 포함할 수 있다. 각각의 층은 한 개 또는 복수 개의 연산노드들을 포함할 수 있다. 도 5에 나타낸 예에서는 입력층은 2개의 노드를 포함하고 있으며, 출력층은 1개의 노드를 포함한 것으로 예시하였다. 도 5에서 각 노드는 문자 N을 포함한 사각형으로 표현하였다.The neural network 420 may include a plurality of layers (layer 1, layer 2, layer 3, layer 4). Each layer may include one or a plurality of operation nodes. In the example shown in FIG. 5 , the input layer includes two nodes and the output layer includes one node. In FIG. 5, each node is expressed as a rectangle including the letter N.
일 실시예에서, 입력층(layer 1)의 각 노드에 입력되는 값은 부동 소수점 또는 고정 소수점 형태의 실수값일 수 있다. 이 경우 입력층(layer 1)의 각 노드는 상기 실수값을 정수값으로 변환하여 출력할 수도 있다. In an embodiment, a value input to each node of the input layer (layer 1) may be a real value in the form of a floating point or a fixed point. In this case, each node of the input layer (layer 1) may convert the real value into an integer value and output it.
다른 실시예에서는 입력층(layer 1)의 각 노드에 입력되는 값은 정수형일 수도 있다. In another embodiment, a value input to each node of the input layer (layer 1) may be an integer type.
그러나 각 층의 각 노드가 출력하는 값은 정수값이며, 정수형 또는 고정 소수점 형태로 표현될 수 있다.However, the value output by each node of each layer is an integer value and can be expressed in integer or fixed-point format.
각 노드를 연결하는 링크에 할당된 가중치 역시 정수값이며, 정수형 또는 고정 소수점 형태로 표현될 수 있다.The weight assigned to the link connecting each node is also an integer value, and may be expressed in an integer or fixed-point format.
출력층(layer 4)에서 출력한 정수값은 상기 신경망(420)이 상기 입력층에 제공되는 실수값으로부터 산출해야 하는 목표값 그 자체는 아니며, 상기 목표값에 비례하는 값이다. The integer value output from the output layer (layer 4) is not the target value itself that the neural network 420 should calculate from the real value provided to the input layer, but is proportional to the target value.
따라서 스케일부(210)에서 상기 출력층이 출력하는 출력 정수값에 출력스케일링 팩터를 적용하여 상기 출력 정수값으로부터 상기 목표값을 복원할 수 있다. 상기 목표값은 정수 또는 실수값일 수 있다. 상기 목표값은 고정 소수점 형태 또는 부동 소수점 형태로 표현될 수 있다. Accordingly, the scale unit 210 may restore the target value from the output integer value by applying an output scaling factor to the output integer value output from the output layer. The target value may be an integer or a real value. The target value may be expressed in a fixed-point form or in a floating-point form.
도 5에서는 설명의 편의를 위하여 신경망(420)의 구조를 간단하게 제시하였으나 실시예에 따라 이보다 더 복잡하게 구현될 수도 있다. 그러나 도 5에 제시된 신경망(420)의 구조로부터 다른 실시예에 따른 더 복잡한 신경망(420)의 구조들도 충분히 이해될 수 있다.Although the structure of the neural network 420 is simply presented in FIG. 5 for convenience of explanation, it may be implemented more complexly than this according to an embodiment. However, from the structure of the neural network 420 shown in FIG. 5 , the more complex structures of the neural network 420 according to another embodiment can be fully understood.
도 5에 나타낸 각 노드들은 모두 정수를 출력하도록 되어 있다. 그리고 각 노드의 입력으로부터 출력을 생성하기 위하여, 상기 각 노드의 내부에 존재하는 곱셈기는 정수간의 곱셈만을 수행하도록 되어 있을 수 있다. 상기 곱셈기는 실수 간의 곱셈을 수행할 필요가 없으므로 그 복잡도가 상대적으로 낮다.Each of the nodes shown in FIG. 5 is configured to output an integer. In addition, in order to generate an output from the input of each node, a multiplier existing inside each node may be configured to perform only integer multiplication. Since the multiplier does not need to perform multiplication between real numbers, its complexity is relatively low.
신경망(420)은 2개 이상의 히든층들을 포함하는 DNN 또는 n-계층 신경망일 수 있다. 예를 들어, 신경망(420)은 입력층(Layer 1), 2개의 히든층들(Layer 2 및 Layer 3) 및 출력층(Layer 4)를 포함하는 DNN일 수 있다. 한편, 신경망(420)는 4개의 층들을 포함하는 것으로 도시되어 있으나, 이는 예시에 불과할 뿐 신경망(420)은 더 적거나 많은 층들을 포함하거나, 더 적거나 많은 채널들을 포함할 수 있다. 즉, 신경망(420)은 다양한 구조의 층들을 포함할 수 있다.The neural network 420 may be a DNN or n-layer neural network including two or more hidden layers. For example, the neural network 420 may be a DNN including an input layer (Layer 1), two hidden layers (Layer 2 and Layer 3), and an output layer (Layer 4). Meanwhile, although the neural network 420 is illustrated as including four layers, this is only an example and the neural network 420 may include fewer or more layers, or fewer or more channels. That is, the neural network 420 may include layers of various structures.
신경망(420)에 포함된 층들 각각은 복수의 채널들을 포함할 수 있다. 채널은 뉴런(neuron), 프로세싱 엘리먼트(Processing element, PE), 유닛(unit) 또는 이와 유사한 용어들로 알려진, 복수의 인공 노드(artificial node)/연산노드/노드들에 해당될 수 있다. 예를 들어, 도 5에 도시된 바와 같이, Layer 1은 2개의 채널들(노드들), Layer 2 및 Layer 3 각각은 3개의 채널들을 포함할 수 있다. 다만, 이는 예시에 불과할 뿐 신경망(420)에 포함된 층들 각각은 다양한 개수의 채널들(노드들)을 포함할 수 있다.Each of the layers included in the neural network 420 may include a plurality of channels. A channel may correspond to a plurality of artificial nodes/computation nodes/nodes known as neurons, processing elements (PEs), units, or similar terms. For example, as shown in FIG. 5 , Layer 1 may include two channels (nodes), and Layer 2 and Layer 3 may each include three channels. However, this is only an example, and each of the layers included in the neural network 420 may include a variable number of channels (nodes).
이하, 도 6 내지 도 10을 이용하여 도 5에 나타낸 신경망의 동작구조를 설명한다.Hereinafter, the operation structure of the neural network shown in FIG. 5 will be described with reference to FIGS. 6 to 10 .
도 6은 도 5에 나타낸 신경망의 입력층의 각 노드에서의 출력 액티베이션의 생성방법을 나타낸 것이다. FIG. 6 shows a method of generating an output activation at each node of the input layer of the neural network shown in FIG. 5 .
입력층(layer 1)의 각 노드(ex: N11)에는 실수값을 갖는 액티베이션이 제공될 수 있다. 상기 실수값은 부동소수점 또는 고정소수점의 형식을 가질 수 있다.Activation having a real value may be provided to each node (eg, N11 ) of the input layer (layer 1). The real value may have a floating-point or fixed-point format.
입력층의 각 노드는 입력된 상기 실수값을 정수값을 갖는 출력 액티베이션으로 변환할 수 있다.Each node of the input layer may convert the input real value into an output activation having an integer value.
상기 실수값이 IA이고 상기 정수값을 qI라고 하면 상기 실수값과 상기 정수값은 [수식 1]의 관계를 갖는다.When the real value is I A and the integer value is q I , the real value and the integer value have a relationship of [Equation 1].
[수식 1][Formula 1]
qI=quantize( IA / SI )q I =quantize( I A / S I )
단, SI는 미리 주어진 입력 스케일링 팩터, IA는 입력 액티베이션(실수), qI는 출력 액티베이션(정수)However, S I is the input scaling factor given in advance, I A is the input activation (real number), q I is the output activation (integer)
수식 1에 따르면, 우선 입력 액티베이션 IA을 미리 주어진 입력 스케일링 팩터 SI로 나눈 값에서 소수점 부분을 제거하여 상기 정수값으로 근사화함으로써 출력 액티베이션 qI를 생성한다. 수식 1에서 연산자 quantize ( )는 실수를 이에 가까운 정수로 근사화하는 연산자이다. According to Equation 1, first, the output activation q I is generated by approximating to the integer value by removing the decimal part from the value obtained by dividing the input activation I A by the input scaling factor S I given in advance. In Equation 1, the operator quantize ( ) is an operator that approximates a real number to an integer close to it.
상기 미리 주어진 입력 스케일링 팩터 SI(=S1)는 입력층의 모든 노드에 대하여 공통적으로 적용될 수 있다.The previously given input scaling factor S I (=S 1 ) may be commonly applied to all nodes of the input layer.
이에 따라 도 6에서 qI1 1=quantize(I1A 1 / SI)로 되고, qI2 1=quantize(I2A 1 / SI)로 될 수 있다. 여기서 S1=SI이다. 그리고 각 항(term)에 붙은 윗첨자는 입력층인 제1층의 층 번호 '1'을 나타낸 것이다.Accordingly, in FIG. 6 , q I1 1 =quantize(I1 A 1 / S I ) and q I2 1 =quantize(I2 A 1 / S I ) may be obtained. where S 1 =S I . And the superscript attached to each term indicates the layer number '1' of the first layer, which is the input layer.
도 6에서 확인되듯이, 입력층의 각 노드의 출력은 정수이다.6 , the output of each node of the input layer is an integer.
후술하겠지만, 상기 입력 스케일링 팩터 SI는 상기 단말기(200)와는 다른 장치, 예컨대 서버로부터 제공받은 것일 수 있다.As will be described later, the input scaling factor S I may be provided from a device different from the terminal 200 , for example, a server.
도 7은 도 5에 나타낸 신경망의 중간층(히든층)의 각 노드에서의 출력 액티베이션의 생성방법을 나타낸 것이다.FIG. 7 shows a method of generating an output activation at each node of an intermediate layer (hidden layer) of the neural network shown in FIG. 5 .
특히 도 7에서는 도 5에 나타낸 신경망의 제2층(layer 2)의 각 노드에서의 출력액티베이션의 생성방법을 나타낸 것이다.In particular, FIG. 7 shows a method of generating output activation at each node of the second layer (layer 2) of the neural network shown in FIG. 5 .
설명의 편의를 위하여 도 7에는 도 5에 제시한 제2층의 노드들 중 제21노드만을 제시하였다.For convenience of explanation, only the 21st node is shown in FIG. 7 among the nodes of the second layer shown in FIG. 5 .
도 6에 제시한 바와 같이 입력층의 노드들(N11, N12)은 출력 액티베이션 qI1 1 및 qI2 1을 출력한다.As shown in FIG. 6 , the nodes N11 and N12 of the input layer output output activations q I1 1 and q I2 1 .
상기 입력층(layer 1)의 하류층인 제2층(layer 2)의 각 노드에는 상기 입력층의 노드들에서 출력된 출력 액티베이션들이 상기 제2층에 대한 입력 액티베이션으로서 입력될 수 있다. 이때, 상기 제2층의 각 노드에는 상기 각각의 입력 액티베이션들 각각에 대응하여 미리 준비된 가중치들(q'w.ab 1)이 입력될 수 있다. Output activations output from the nodes of the input layer may be input to each node of the second layer (layer 2) that is a downstream layer of the input layer (layer 1) as input activations for the second layer. In this case, pre-prepared weights q' w.ab 1 corresponding to each of the respective input activations may be input to each node of the second layer.
제2층의 임의의 노드(a)의 출력 액티베이션 qIa 2는 [수식 2]와 같이 제시될 수 있다.The output activation q Ia 2 of an arbitrary node (a) in the second layer may be expressed as in [Equation 2].
[수식 2][Equation 2]
qIa 2= Right_Shift { n2, ( qI1 1*q'w.a1 1 + qI2 1*q'w.a2 1 + b21 ) }q Ia 2 = Right_Shift { n2 , ( q I1 1 *q' w.a1 1 + q I2 1 *q' w.a2 1 + b 21 ) }
단, 윗 첨자는 층 번호를 나타내며, Right_Shift {n2,x}는 x를 우측으로 n2 비트 시프트하는 연산을 나타냄.However, the superscript indicates the layer number, and Right_Shift { n2,x } indicates an operation that shifts x to the right by n2 bits.
수식 2에서 곱셈 연산이 수행되는데, 상기 곱셈은 정수간의 곱셈이므로 두 개의 정수를 서로 곱하는 연산이면 충분하다. 이는 실수간의 곱셈을 수행하는 연산기에 비하여 하드웨어 자원을 적게 소비한다는 장점이 있다.A multiplication operation is performed in Equation 2, and since the multiplication is multiplication between integers, an operation for multiplying two integers is sufficient. This has the advantage of consuming less hardware resources than an operator performing multiplication between real numbers.
또한 수식 2 및 도 7을 살펴보면, 곱셈 연산기는 합산 연산기의 상류에만 제공되면 되며, 합산 연산기의 하류에는 제공될 필요가 없다. 합산 연산기의 하류에는 Right_Shift 연산기만 제공되면 된다.Also, referring to Equation 2 and FIG. 7 , the multiplication operator only needs to be provided upstream of the summation operator, and does not need to be provided downstream of the summation operator. Only the Right_Shift operator needs to be provided downstream of the summation operator.
수식 2의 q'w.ab 1에서 a는 상기 제2층의 노드를 식별하는 인덱스를 나타내고 b는 상기 제2층의 상류인 제1층의 노드를 식별하는 인덱스를 나타내며, 윗첨자는 층 번호를 나타낸다. 즉, 도 5에 나타낸 신경망(420)의 각 링크에 할당되는 가중치는, 상기 가중치가 제공되는 층의 번호, 그리고 상기 각 링크의 소스 노드 및 목표 노드에 따라 독립적으로 제공되는 값일 수 있다.In q' w.ab 1 of Equation 2, a denotes an index identifying a node of the second layer, b denotes an index identifying a node of a first layer upstream of the second layer, and a superscript is a layer number indicates That is, the weight assigned to each link of the neural network 420 shown in FIG. 5 may be a value independently provided according to the number of the layer to which the weight is provided, and a source node and a target node of each link.
후술하겠지만, 각 가중치 q'w.ab Layer_L는 상기 단말기(200)와는 다른 장치, 예컨대 서버가 단말기(200)에게 제공하는 값일 수 있다.As will be described later, each weight q' w.ab Layer_L may be a value provided to the terminal 200 by a device different from the terminal 200 , for example, a server.
도 7에서 상기 제2층의 각 노드의 입력 및 출력은 모두 정수임을 알 수 있다. It can be seen from FIG. 7 that both the input and output of each node of the second layer are integers.
도 7에 나타낸 b21은 노드(N21)에 적용된 바이어스로서 정수값을 가질 수 있다. b 21 shown in FIG. 7 is a bias applied to the node N21 and may have an integer value.
도 8은 도 5에 나타낸 신경망의 중간층(히든층)의 각 노드에서의 출력생성방법을 나타낸 것이다.FIG. 8 shows an output generation method at each node of the intermediate layer (hidden layer) of the neural network shown in FIG. 5 .
특히 도 8에서는 도 5에 나타낸 신경망(420)의 제3층(layer 3)의 각 노드에서의 출력 액티베이션의 생성방법을 나타낸 것이다.In particular, FIG. 8 shows a method of generating output activation at each node of the third layer (layer 3) of the neural network 420 shown in FIG. 5 .
설명의 편의를 위하여 도 8에는 도 5에 제시한 제3층의 노드들 중 제31노드(N31)만을 제시하였다.For convenience of explanation, only the 31st node N31 is shown in FIG. 8 among the nodes of the third layer shown in FIG. 5 .
도 7에 도시하지는 않았지만 제2층의 제22노드(N22)는 출력 액티베이션 qI2 2를 출력하고, 제2층의 제23노드(N23)는 출력 액티베이션 qI3 2를 출력한다.Although not shown in FIG. 7 , the 22nd node N22 of the second layer outputs the output activation q I2 2 , and the 23rd node N23 of the second layer outputs the output activation q I3 2 .
상기 제2층의 하류층인 제3층의 각 노드에는 상기 제2층의 노드들에서 출력된 출력 액티베이션들이 상기 제3층에 대한 입력 액티베이션으로서 입력될 수 있다. 이때, 상기 제3층의 각 노드에는 상기 각각의 입력 액티베이션들 각각에 대응하여 미리 준비된 가중치들(q'w.ab 2)이 입력될 수 있다. Output activations output from the nodes of the second layer may be input to each node of the third layer, which is a downstream layer of the second layer, as input activations for the third layer. In this case, pre-prepared weights q' w.ab 2 corresponding to each of the respective input activations may be input to each node of the third layer.
도 8에 제시한 바와 같이 제3층의 제31노드(N31)는 출력 액티베이션 qI1 3를 출력한다. As shown in FIG. 8 , the 31st node N31 of the third layer outputs an output activation q I1 3 .
제3층의 임의의 노드(a)의 출력 액티베이션 qIa 3는 [수식 3]와 같이 제시될 수 있다.The output activation q Ia 3 of an arbitrary node (a) of the third layer may be expressed as in [Equation 3].
[수식 3][Equation 3]
qIa 3= Right_Shift { n3, ( qI1 2*q'w.a1 2 + qI2 2*q'w.a2 2 + qI3 2*q'w.a3 2 + b31 ) }q Ia 3 = Right_Shift { n3 , ( q I1 2 *q' w.a1 2 + q I2 2 *q' w.a2 2 + q I3 2 *q' w.a3 2 + b 31 ) }
단, 윗 첨자는 층 번호를 나타내며, Right_Shift {n,x}는 x를 우측으로 n3 비트 시프트하는 연산을 나타냄.However, the superscript indicates the layer number, and Right_Shift { n,x } indicates an operation that shifts x to the right by n3 bits.
수식 3에서 곱셈 연산이 수행되는데, 상기 곱셈은 정수간의 곱셈이므로 두 개의 정수를 서로 곱하는 연산이면 충분하다. A multiplication operation is performed in Equation 3, and since the multiplication is multiplication between integers, an operation for multiplying two integers is sufficient.
수식 3의 q'w.ab 2에서 a는 상기 제3층의 노드를 식별하는 인덱스를 나타내고 b는 상기 제3층의 상류인 제2층의 노드를 식별하는 인덱스를 나타내며, 윗첨자는 층 번호를 나타낸다. In q' w.ab 2 of Equation 3, a represents an index for identifying a node of the third layer, b represents an index for identifying a node of a second layer upstream of the third layer, and the superscript is a layer number indicates
도 8에 나타낸 b31은 노드(N31)에 적용된 바이어스로서 정수값을 가질 수 있다. b 31 shown in FIG. 8 is a bias applied to the node N31 and may have an integer value.
도 9는 도 5에 나타낸 신경망의 출력층의 각 노드에서의 출력생성방법을 나타낸 것이다.FIG. 9 shows an output generation method at each node of the output layer of the neural network shown in FIG. 5 .
특히 도 9에서는 도 5에 나타낸 신경망(420)의 제4층(출력층)의 각 노드에서의 출력액티베이션의 생성방법을 나타낸 것이다.In particular, FIG. 9 shows a method of generating output activation at each node of the fourth layer (output layer) of the neural network 420 shown in FIG. 5 .
설명의 편의를 위하여 도 9에는 도 5에 제시한 출력층의 노드들 중 제41노드(N41)를 제시하였다.For convenience of explanation, a 41 th node N41 among the nodes of the output layer shown in FIG. 5 is shown in FIG. 9 .
도 8에 도시하지는 않았지만 제3층의 제32노드(N32)는 출력 액티베이션 qI2 3를 출력하고, 제3층의 제33노드(N33)는 출력 액티베이션 qI3 3를 출력한다.Although not shown in FIG. 8 , the 32nd node N32 of the third layer outputs the output activation q I2 3 , and the 33rd node N33 of the third layer outputs the output activation q I3 3 .
상기 제3층의 하류층인 제4층(=출력층)의 각 노드에는 상기 제3층의 노드들에서 출력된 출력 액티베이션들이 상기 제4층에 대한 입력 액티베이션으로서 입력될 수 있다. 이때, 상기 제4층의 각 노드에는 상기 각각의 입력 액티베이션들 각각에 대응하여 미리 준비된 가중치들(q'w.ab 3)이 입력될 수 있다. Output activations output from the nodes of the third layer may be input to each node of the fourth layer (=output layer) that is a downstream layer of the third layer as input activations for the fourth layer. In this case, pre-prepared weights q' w.ab 3 corresponding to each of the respective input activations may be input to each node of the fourth layer.
도 9에 제시한 바와 같이 제4층의 제41노드(N41)는 출력 액티베이션 qI1 4(=qO1)를 출력한다. As shown in FIG. 9 , the 41st node N41 of the fourth layer outputs an output activation q I1 4 (=q O1 ).
제4층의 임의의 노드의 출력 액티베이션 qIa 4는 [수식 4]와 같이 제시될 수 있다.The output activation q Ia 4 of any node of the fourth layer may be expressed as [Equation 4].
[수식 4][Equation 4]
qIa 4= Right_Shift { n4, ( qI1 3*q'w.a1 3 + qI2 3*q'w.a2 3 + qI3 3*q'w.a3 3 + b41 ) }q Ia 4 = Right_Shift { n4 , ( q I1 3 *q' w.a1 3 + q I2 3 *q' w.a2 3 + q I3 3 *q' w.a3 3 + b 41 ) }
단, 윗 첨자는 층 번호를 나타내며, Right_Shift {n,x}는 x를 우측으로 n4 비트 시프트하는 연산을 나타냄.However, the superscript indicates the layer number, and Right_Shift { n,x } indicates an operation that shifts x to the right by n4 bits.
수식 4에서 곱셈 연산이 수행되는데, 상기 곱셈은 정수간의 곱셈이므로 두 개의 정수를 서로 곱하는 연산이면 충분하다. A multiplication operation is performed in Equation 4, and since the multiplication is multiplication between integers, an operation for multiplying two integers is sufficient.
수식 4의 q'w.ab 2에서 a는 상기 제4층의 노드를 식별하는 인덱스를 나타내고 b는 상기 제4층의 상류인 제3층의 노드를 식별하는 인덱스를 나타내며, 윗첨자는 층 번호를 나타낸다. In q' w.ab 2 of Equation 4, a represents an index for identifying a node of the fourth layer, b represents an index for identifying a node of a third layer upstream of the fourth layer, and the superscript is a layer number indicates
도 9에 나타낸 b41은 노드(N41)에 적용된 바이어스로서 정수값을 가질 수 있다. b 41 shown in FIG. 9 is a bias applied to the node N41 and may have an integer value.
수식 2, 수식 3, 수식 4에 제시된 n2, n3, n4로부터 선택된 임의의 두 개위 수는 서로 다를 수도 있고 동일할 수도 있다. Any two distinct numbers selected from n2, n3, and n4 shown in Equation 2, Equation 3, and Equation 4 may be different from or the same as each other.
도 7 내지 도 9를 이용한 상술한 설명으로부터 도 5의 신경망(420)의 히든층 및 출력층인 층(L+1)의 각 노드(a)가 출력하는 출력 액티베이션(qIa Layer_L+1)은 [수식 5]와 같이 제시될 수 있음을 이해할 수 있다.From the above description using FIGS. 7 to 9, the output activation (q Ia Layer_L+1 ) output by each node (a) of the layer (L+1) that is the hidden layer and the output layer of the neural network 420 of FIG. 5 is [ It can be understood that it can be presented as Equation 5].
[수식 5][Equation 5]
qIa Layer_L+1= Right_Shift { n, sum ( qIb Layer_N * q'w.ab Layer_N , a=1, 2, 3, ..., b=1, 2, 3, ....) }q Ia Layer_L+1 = Right_Shift { n , sum ( q Ib Layer_N * q' w.ab Layer_N , a=1, 2, 3, ..., b=1, 2, 3, .... ) }
단, a는 층 L+1의 특정 노드의 인덱스이고, b는 층 L의 특정 노드의 인덱스이며, q'w.ab Layer_N는 층 L의 노드 b로부터 층 L+1의 노드 a로 연결되는 링크에 할당된 가중치임However, a is an index of a specific node of layer L+1, b is an index of a specific node of layer L, and q' w.ab Layer_N is a link from node b of layer L to node a of layer L+1 is the weight assigned to
도 10은 도 5에 나타낸 신경망의 출력층의 각 노드에서 출력한 출력 정수값으로부터 목표값을 복원하는 방법을 나타낸 것이다.10 is a diagram illustrating a method of restoring a target value from an output integer value output from each node of the output layer of the neural network shown in FIG. 5 .
출력층에 속한 노드가 출력한 출력 정수값(qO)으로부터 스케일부(210)가 복원하는 복원값(OA)은 [수식 6]과 같은 관계를 갖는다.The restored value O A restored by the scale unit 210 from the output integer value q O output by the node belonging to the output layer has the same relationship as [Equation 6].
[수식 6][Equation 6]
OA=qOㆍSO O A =q O ㆍS O
단, SO는 미리 주어진 출력층 스케일 팩터.However, S O is a pre-given output layer scale factor.
수식 6에 따라, 도 10에서 O1A=qO1ㆍSO 및 O2A=qO2ㆍSO이 성립한다.According to Equation 6, O1 A =q O1 ㆍS O and O2 A =q O2 ㆍS O are established in FIG. 10 .
출력층에 속한 노드가 출력한 출력 정수값(qO)을 갖지만, 스케일부가 출력한 복원값은 고정소수점 형식 또는 부동소수점 형식의 실수형으로 표현될 수 있다.Although it has an output integer value (q O ) output by a node belonging to the output layer, the restored value output by the scale unit may be expressed in a real number of a fixed-point format or a floating-point format.
후술하겠지만, SO는 단말기와는 다른 장치, 예컨대 서버가 상기 단말기(200)에게 제공하는 값일 수 있다.As will be described later, SO may be a value provided to the terminal 200 by a device other than the terminal, for example, a server.
도 5에 나타낸 신경망(420)의 히든층들 및 출력층의 각 노드에서 수행되는 Right_Shift 연산은 모두 n비트 시프트일 수 있다.The Right_Shift operation performed at each node of the hidden layers and the output layer of the neural network 420 shown in FIG. 5 may all be an n-bit shift.
도 5에 나타낸 신경망(420)의 각 노드의 출력값은 모두 n비트 인티져이고, 각 가중치의 값 역시 모두 n비트 인티져이다.The output values of each node of the neural network 420 shown in FIG. 5 are all n-bit integers, and the values of each weight are also all n-bit integers.
도 11은 서버에서 상기 단말기에게 제공하는 정보를 나타낸 것이다.11 shows information provided by the server to the terminal.
서버(100)는 상술한 입력층 스케일링 팩터(SI) 및 출력층 스케일링 팩터(SO)를 단말기(200)에게 제공할 수 있다.The server 100 may provide the above-described input layer scaling factor (S I ) and output layer scaling factor (SO ) to the terminal 200 .
또한 서버(100)는 상술한 모든 가중치들을 단말기(200)에게 제공할 수 있다.Also, the server 100 may provide all the above-described weights to the terminal 200 .
또한 서버(100)는 상기 n비트 Right-Shift 연산에 이용되는 n값을 단말기(200)에게 제공할 수 있다. In addition, the server 100 may provide the terminal 200 with an n value used for the n-bit Right-Shift operation.
상기 Right-Shift 연산에 이용되는 n값은 각 층마다 독립적으로 설정될 수 있다. 따라서, 서버(100)는 본 발명의 일 실시예에 따라 제공되는 정수형 신경망의 각 층마다 할당되어야 하는 n값들을 단말기(200)에게 제공할 수 있다. The n value used for the right-shift operation may be independently set for each layer. Accordingly, the server 100 may provide the terminal 200 with n values to be assigned to each layer of the integer neural network provided according to an embodiment of the present invention.
이를 위하여 서버(100)는 상술한 데이터들을 생성할 수 있어야 한다. 이 방법은 도 12를 통해 설명한다.To this end, the server 100 must be able to generate the above-described data. This method will be described with reference to FIG. 12 .
단말기(200)가 이미 신경망의 층의 개수, 노드의 개수, 링크의 개수 등 신경망과 관련된 구조정보를 이미 갖고 있다고 가정할 수 있다. 이때, 서버(100)는 단말기(200)에게 상기 입력층 스케일링 팩터(SI), 출력층 스케일링 팩터(SO), 가중치들, 그리고 상기 n비트 Right-Shift 연산에 이용되는 n값만을 제공할 수 있다.It can be assumed that the terminal 200 already has structural information related to the neural network, such as the number of layers of the neural network, the number of nodes, and the number of links. At this time, the server 100 may provide the terminal 200 with only the input layer scaling factor ( SI ), the output layer scaling factor (SO ), weights, and n values used for the n-bit Right-Shift operation. there is.
만일, 단말기(200)가 상기 신경망의 구조정보를 갖고 있지 않다면, 서버(100)는 단말기(200)에게 상술한 정보들 뿐만 아니라 신경망의 구조정보 역시 제공해야 할 수 있다.If the terminal 200 does not have the structure information of the neural network, the server 100 may have to provide not only the above-mentioned information but also the structure information of the neural network to the terminal 200 .
도 12는 서버에서 학습 완료한 신경망의 구조를 나타낸다. 도 12에 나타낸 신경망(410)은 도 5에 나타낸 신경망(420)에 대응하는 구조를 갖는다. 12 shows the structure of a neural network that has been trained by the server. The neural network 410 shown in FIG. 12 has a structure corresponding to the neural network 420 shown in FIG. 5 .
상기 학습 완료된 신경망(410)의 각 링크에 할당된 가중치(w.ab)는 실수값일 수 있다. 상기 실수값은 고정 소수점 방식 또는 부동 소수점 방식으로 표현된 것일 수 있다.The weight w.ab assigned to each link of the learned neural network 410 may be a real value. The real value may be expressed in a fixed-point method or a floating-point method.
도 12에 예시한 신경망(410)은 입력층과 출력층을 포함하여 총 4개의 층으로 구성되어 있다. 각 층에는 이에 대응하는 스케일링 팩터가 할당된다. 상기 스케일링 팩터의 값은 임의의 값으로 결정할 수도 있지만, 바람직한 실시예에서는 잘 설계된 방식에 따라 결정될 수도 있다. 예컨대 공개특허 10-2019-0014900에는 각 층에 할당된 스케일링 팩터를 생성하는 예가 제시되어 있다. The neural network 410 illustrated in FIG. 12 includes a total of four layers including an input layer and an output layer. Each layer is assigned a corresponding scaling factor. The value of the scaling factor may be determined as an arbitrary value, but in a preferred embodiment may be determined according to a well-designed method. For example, Patent Publication No. 10-2019-0014900 provides an example of generating a scaling factor assigned to each layer.
결정된 상기 스케일링 팩터들 중 입력층에 할당된 입력층 스케일링 팩터(SI=S1) 및 출력층에 할당된 출력층 스케일링 팩터(SO=S4)는 단말기(200)에 제공될 수 있다. Among the determined scaling factors, the input layer scaling factor (S I =S 1 ) allocated to the input layer and the output layer scaling factor (S O =S 4 ) allocated to the output layer may be provided to the terminal 200 .
히든층에 할당된 스케일링 팩터들(S2, S3)은 단말기(200)에 제공될 필요는 없으나, 단말기(200)에 제공되어야 하는 상기 각각의 가중치(qa Layer_L)를 산출하는 과정에 이용될 수 있다.The scaling factors S 2 , S 3 allocated to the hidden layer do not need to be provided to the terminal 200 , but are used in the process of calculating the respective weights q a Layer_L to be provided to the terminal 200 . can be
서버(100)가 단말기(200)에 제공해야 하는 가중치를 수식 7에 의해 산출될 수 있다. The weight to be provided by the server 100 to the terminal 200 may be calculated by Equation 7.
[수식 7][Equation 7]
q'w.ab layer_L = quantize ((SLayer_L/SLayer_L+1) * w.abLayer_L * 2n)q' w.ab layer_L = quantize ((S Layer_L /S Layer_L+1 ) * w.ab Layer_L * 2 n )
단, layer_L은 L번째 층을 나타내고, However, layer_L represents the L-th layer,
layer_L+1은 L+1번째 층을 나타내고, layer_L+1 represents the L+1-th layer,
SLayer_L은 L번째 층에 부여된 스케일링 팩터를 나타내고, S Layer_L represents the scaling factor given to the L-th layer,
SLayer_L+1은 L+1번째 층에 부여된 스케일링 팩터를 나타내고, S Layer_L+1 represents the scaling factor given to the L+1-th layer,
w.abLayer_L는 L번째 층의 노드 b에서 L+1번째 층의 노드 a로 향하는 링크에 부여된 가중치를 나타내며,w.ab Layer_L represents the weight given to the link from node b of the Lth layer to the node a of the L+1th layer,
q'w.ab layer_L은 n비트 인티져로서, 서버가 단말기에게 제공하기 위하여 w.abLayer_L로부터 얻은 양자화된 가중치임.q' w.ab layer_L is an n-bit integer, which is a quantized weight obtained from w.ab Layer_L for the server to provide to the terminal.
도 13a는 본 발명의 일 실시예에 따른 서버의 하드웨어 구성을 도시한 블록도이다. 상기 서버는 신경망 양자화 장치라고 지칭될 수도 있다.13A is a block diagram illustrating a hardware configuration of a server according to an embodiment of the present invention. The server may be referred to as a neural network quantization device.
도 13a를 참고하면, 서버(100)는 프로세서(110) 및 메모리(120)를 포함한다. 도 13a에 도시된 서버(100)에는 본 실시예들과 관련된 구성요소들만이 도시되어 있다. 따라서, 서버(100)에는 도 13a에 도시된 구성요소들 외에 다른 범용적인 구성요소들이 더 포함될 수 있음은 당업자에게 자명하다.Referring to FIG. 13A , the server 100 includes a processor 110 and a memory 120 . In the server 100 shown in FIG. 13A, only the components related to the present embodiments are shown. Accordingly, it is apparent to those skilled in the art that other general-purpose components may be further included in the server 100 in addition to the components illustrated in FIG. 13A .
서버(100)는 신경망(410)을 생성하거나, 신경망(410)을 훈련(train)(또는 학습(learn))하거나, 부동 소수점 타입의 신경망(410)을 고정 소수점 타입의 신경망(420)으로 양자화하거나, 또는 신경망(410)을 재훈련(retrain)하는 기능들과 같은 다양한 프로세싱 기능들을 갖는 컴퓨팅 디바이스에 해당된다. 예를 들어, 서버(100)는 PC(personal computer), 서버 디바이스, 모바일 디바이스 등의 다양한 종류의 디바이스들로 구현될 수 있다.The server 100 generates a neural network 410, trains (or learns) the neural network 410, or quantizes a floating-point type neural network 410 into a fixed-point type neural network 420. Or, it corresponds to a computing device having various processing functions, such as functions to retrain the neural network 410 . For example, the server 100 may be implemented with various types of devices such as a personal computer (PC), a server device, and a mobile device.
프로세서(110)는 서버(100)를 제어하기 위한 전반적인 기능을 수행하는 역할을 한다. 예를 들어, 프로세서(110)는 서버(100) 내의 메모리(120)에 저장된 프로그램들을 실행함으로써, 서버(100)를 전반적으로 제어한다. 프로세서(110)는 서버(100) 내에 구비된 CPU(central processing unit), GPU(graphics processing unit), AP(application processor) 등으로 구현될 수 있으나, 이에 제한되지 않는다.The processor 110 serves to perform an overall function for controlling the server 100 . For example, the processor 110 generally controls the server 100 by executing programs stored in the memory 120 in the server 100 . The processor 110 may be implemented as a central processing unit (CPU), a graphics processing unit (GPU), an application processor (AP), etc. provided in the server 100 , but is not limited thereto.
메모리(120)는 서버(100) 내에서 처리되는 각종 데이터들을 저장하는 하드웨어로서, 예를 들어, 메모리(120)는 서버(100)에서 처리된 데이터들 및 처리될 데이터들을 저장할 수 있다. 또한, 메모리(120)는 서버(100)에 의해 구동될 애플리케이션들, 드라이버들 등을 저장할 수 있다. 메모리(120)는 DRAM일 수 있으나, 이에 한정되는 것은 아니다. 메모리(120)는 휘발성 메모리(volatile memory) 또는 불휘발성 메모리(nonvolatile memory) 중 적어도 하나를 포함할 수 있다. 불휘발성 메모리는 ROM (Read Only Memory), PROM (Programmable ROM), EPROM (Electrically Programmable ROM), EEPROM (Electrically Erasable and Programmable ROM), 플래시 메모리, PRAM (Phase-change RAM), MRAM (Magnetic RAM), RRAM (Resistive RAM), FRAM (Ferroelectric RAM) 등을 포함한다. 휘발성 메모리는 DRAM (Dynamic RAM), SRAM (Static RAM), SDRAM (Synchronous DRAM), PRAM (Phase-change RAM), MRAM (Magnetic RAM), RRAM (Resistive RAM), FeRAM (Ferroelectric RAM) 등을 포함한다. 실시예에 있어서, 메모리(1940)는 HDD(Hard Disk Drive), SSD(Solid State Drive), CF(compact flash), SD(secure digital), Micro-SD(micro secure digital), Mini-SD(mini secure digital), xD(extreme digital) 또는 Memory Stick 중 적어도 하나를 포함할 수 있다.The memory 120 is hardware for storing various types of data processed in the server 100 , and for example, the memory 120 may store data processed by the server 100 and data to be processed. In addition, the memory 120 may store applications to be driven by the server 100 , drivers, and the like. The memory 120 may be a DRAM, but is not limited thereto. The memory 120 may include at least one of a volatile memory and a nonvolatile memory. Non-volatile memory includes ROM (Read Only Memory), PROM (Programmable ROM), EPROM (Electrically Programmable ROM), EEPROM (Electrically Erasable and Programmable ROM), Flash memory, PRAM (Phase-change RAM), MRAM (Magnetic RAM), RRAM (Resistive RAM), FRAM (Ferroelectric RAM), and the like. Volatile memory includes DRAM (Dynamic RAM), SRAM (Static RAM), SDRAM (Synchronous DRAM), PRAM (Phase-change RAM), MRAM (Magnetic RAM), RRAM (Resistive RAM), FeRAM (Ferroelectric RAM), etc. . In an embodiment, the memory 1940 is a hard disk drive (HDD), solid state drive (SSD), compact flash (CF), secure digital (SD), micro secure digital (Micro-SD), mini-SD (mini). secure digital), xD (extreme digital), or Memory Stick.
프로세서(110)는 주어진 초기 신경망을 반복적으로 훈련(학습)시킴으로써, 훈련된 신경망(410)을 생성할 수 있다. 이때, 초기 신경망은 신경망의 처리 정확도 확보 차원에서 부동 소수점 타입의 파라미터들, 예를 들어 32비트 부동 소수점 정밀도(32bit floating point precision)의 파라미터들을 가질 수 있다. 여기서, 파라미터들은 예를 들어 신경망의 입/출력 액티베이션들, 가중치들, 바이어스들 등 신경망에 입/출력되는 다양한 종류의 데이터를 포함할 수 있다. 신경망의 반복적인 훈련이 진행됨에 따라, 신경망의 부동 소수점 파라미터들은 주어진 입력에 대해 보다 정확한 출력을 연산하기 위해 조정될(tuned) 수 있다.The processor 110 may generate the trained neural network 410 by repeatedly training (learning) a given initial neural network. In this case, the initial neural network may have floating-point type parameters, for example, parameters of 32-bit floating point precision in order to secure processing accuracy of the neural network. Here, the parameters may include various types of data input/output to the neural network, such as input/output activations, weights, and biases of the neural network. As the neural network iteratively trains, the floating-point parameters of the neural network can be tuned to compute a more accurate output for a given input.
부동 소수점은 고정 소수점에 비해 상대적으로 많은 연산량과 많은 메모리 액세스 빈도가 요구된다. 특히, 신경망의 처리에 소요되는 연산량의 대부분은 다양한 파라미터들의 연산을 수행하는 컨볼루션 연산으로 알려져 있다. 따라서, 비교적 처리 성능이 낮은 스마트폰, 태블릿, 웨어러블 디바이스 등과 같은 모바일 디바이스, 임베디드(embedded) 디바이스 등에서는 부동 소수점 타입의 파라미터들을 갖는 신경망(410)의 처리가 원활하지 않을 수 있다. 결국, 본 발명의 일 실시예에 따른 서버(100)는 이와 같은 디바이스들에서 연산량을 충분히 감소시키면서 허용 가능한 정확도 손실 내에서 신경망을 구동시키기 위해서는, 신경망(410)에서 처리되는 부동 소수점 타입의 파라미터들은 양자화할 수 있다. 여기서, 파라미터 양자화는, 부동 소수점 타입의 파라미터를, 정수 값을 갖는 고정 소수점 타입의 파라미터로 변환하는 것을 의미한다.Floating point requires a relatively large amount of computation and memory access frequency compared to fixed point. In particular, it is known that most of the amount of computation required for processing a neural network is a convolution operation that performs computation of various parameters. Accordingly, in mobile devices such as smartphones, tablets, wearable devices, etc., which have relatively low processing performance, embedded devices, etc., the processing of the neural network 410 having floating-point type parameters may not be smooth. After all, in order for the server 100 according to an embodiment of the present invention to drive the neural network within an allowable loss of accuracy while sufficiently reducing the amount of computation in such devices, the floating-point type parameters processed in the neural network 410 are can be quantized. Here, parameter quantization means converting a floating-point type parameter into a fixed-point type parameter having an integer value.
서버(100)는 신경망이 채용될(deployed) 디바이스(예를 들어, 모바일 디바이스, 임베디드 디바이스 등)의 처리 성능을 고려하여, 훈련된 신경망(410)의 파라미터들을 소정 비트들의 고정 소수점 타입으로 변환하는 양자화를 수행하고, 서버(100)는 양자화된 신경망(420)을 채용될 디바이스에 전달한다. 신경망(420)이 채용될 디바이스는 상술한 단말기(200)일 수 있다. 구체적인 예시로 신경망을 이용한 음성 인식, 영상 인식 등을 수행하는 자율주행 자동차, 로보틱스, 스마트폰, 태블릿 디바이스, AR(Augmented Reality) 디바이스, IoT(Internet of Things) 디바이스 등일 수 있으나, 이에 제한되지 않는다.The server 100 converts the parameters of the trained neural network 410 into a fixed-point type of predetermined bits in consideration of the processing performance of the device (eg, mobile device, embedded device, etc.) to which the neural network is to be deployed (eg, mobile device, embedded device, etc.) After performing quantization, the server 100 transmits the quantized neural network 420 to the device to be employed. The device to which the neural network 420 is to be employed may be the aforementioned terminal 200 . Specific examples include, but are not limited to, autonomous vehicles, robotics, smart phones, tablet devices, augmented reality (AR) devices, and Internet of Things (IoT) devices that perform voice recognition and image recognition using neural networks.
프로세서(110)는 메모리(120)에 저장된, 부동 소수점들을 이용하여 미리 훈련된(pre-trained) 신경망(410)의 데이터를 획득한다. 미리 훈련된 신경망(410)은 부동 소수점 타입의 파라미터들로 반복적으로 훈련된 데이터일 수 있다. 신경망의 훈련은, 훈련-세트(train set) 데이터를 입력으로 하여 먼저 반복적으로 훈련되고, 이어서 테스트-세트(test set) 데이터로 다시 반복적으로 훈련된 것일 수 있으나, 반드시 이에 제한되지 않는다. 훈련-세트 데이터는 신경망을 훈련시키기 위한 입력 데이터이고, 테스트 세트 데이터는 훈련-세트 데이터와 겹치지 않는 입력 데이터로서, 훈련-세트 데이터로 훈련된 신경망의 성능을 측정하면서 훈련시키기 위한 데이터이다.The processor 110 obtains data of the neural network 410 that is pre-trained using floating points, stored in the memory 120 . The pretrained neural network 410 may be data repeatedly trained with floating-point type parameters. Training of the neural network may be first iteratively trained with training-set data as input, and then iteratively trained again with test-set data, but is not necessarily limited thereto. The training-set data is input data for training a neural network, and the test set data is input data that does not overlap with the training-set data, and is data for training while measuring the performance of a neural network trained with the training-set data.
일 실시예에서, 프로세서(110)는 미리 훈련된 신경망 데이터로부터, 피처 맵들 및 커널들 각각에 포함된 각 층에서 이용된 부동 소수점 타입의 파라미터 값들에 대한 채널 별 통계적 분포를 분석할 수 있다. 프로세서(110)는 분석된 층 별 통계적 분포에 기초하여, 상술한 각 층에 대응하는 상기 스케일링 팩터들을 결정할 수 있다. 예컨대, 상술한 q'w.ab Layer_L 값이 n bit integer 형태에서 충분한 해상력을 가지도록 스케일링 팩터들이 결정될 수 있다.In an embodiment, the processor 110 may analyze the statistical distribution for each channel of the floating-point type parameter values used in each layer included in each of the feature maps and the kernels from the pre-trained neural network data. The processor 110 may determine the scaling factors corresponding to each of the above-described layers based on the analyzed statistical distribution for each layer. For example, the scaling factors may be determined so that the above-described q' w.ab Layer_L value has sufficient resolution in the form of an n bit integer.
한편, 메모리(120)는 예를 들어, 훈련되지 않은 초기 신경망 데이터, 훈련 과정에서 생성된 신경망 데이터, 모든 훈련이 완료된 신경망 데이터, 양자화된 신경망 데이터 등 프로세서(110)에 의해 처리될 또는 처리된 신경망 관련 데이터 세트를 저장할 수 있고, 또한 프로세서(110)에 의해 실행될 신경망의 훈련 알고리즘, 양자화 알고리즘 등에 관련된 다양한 프로그램들을 저장할 수 있다.On the other hand, the memory 120 is, for example, untrained initial neural network data, neural network data generated in the training process, neural network data for which all training has been completed, quantized neural network data, etc. to be processed or processed by the processor 110 . A related data set may be stored, and various programs related to a training algorithm of a neural network, a quantization algorithm, etc. to be executed by the processor 110 may be stored.
도 13b는 본 발명의 일 실시예에 따른 미리 훈련된 신경망을 양자화하여 단말기(하드웨어 가속기)에 채용하는 것을 설명하기 위한 도면이다.13B is a diagram for explaining the quantization of a pre-trained neural network according to an embodiment of the present invention and employing it in a terminal (hardware accelerator).
도 13b를 참고하면, 앞서 설명된 바와 같이, PC, 서버 등과 같은 서버(도 13a의 100)에서 프로세서(도 13a의 110)는 부동 소수점 타입(예를 들어, 32비트 부동 소수점 타입)의 신경망을 훈련한다. 미리 훈련된 신경망(410) 자체는 부동 소수점 타입의 파라미터들로 인하여 저전력 또는 저성능의 하드웨어 가속기에서 효율적으로 처리되지 않을 수 있으므로, 서버(100)의 프로세서(110)는 부동 소수점 타입의 신경망(410)를 고정 소수점 타입(예를 들어, 16비트 이하의 고정 소수점 타입)의 신경망(420)로 양자화한다. 단말기(하드웨어 가속기)는 신경망(420)의 구동을 위한 전용 하드웨어로서, 비교적 저전력 또는 저성능으로 구현되기 때문에 부동 소수점 연산 보다는 고정 소수점 연산에 보다 적합하게 구현될 수 있다. 하드웨어 가속기는 예를 들어, 신경망 구동을 위한 전용 모듈인 NPU(neural processing unit), TPU(Tensor Processing Unit), Neural Engine 등에 해당될 수 있으나, 이에 제한되지 않는다.Referring to FIG. 13B, as described above, in a server (100 in FIG. 13A), such as a PC, a server, etc., the processor (110 in FIG. 13A) is a floating-point type (eg, 32-bit floating-point type) neural network train Since the pretrained neural network 410 itself may not be efficiently processed in a low-power or low-performance hardware accelerator due to floating-point type parameters, the processor 110 of the server 100 operates the floating-point type neural network 410 ) is quantized into the neural network 420 of a fixed-point type (eg, a fixed-point type of 16 bits or less). The terminal (hardware accelerator) is dedicated hardware for driving the neural network 420 , and since it is implemented with relatively low power or low performance, it may be implemented more suitable for a fixed-point operation rather than a floating-point operation. The hardware accelerator may correspond to, for example, a neural processing unit (NPU), a tensor processing unit (TPU), a neural engine, etc. which are dedicated modules for driving a neural network, but is not limited thereto.
양자화된 신경망(420)를 구동하는 하드웨어 가속기는, 서버(100)와는 별도의 독립적인 디바이스에 구현될 수 있다. 하지만, 이에 제한되지 않고, 하드웨어 가속기는 서버(100)와 동일한 장치 내에도 구현될 수 있다.The hardware accelerator for driving the quantized neural network 420 may be implemented in an independent device separate from the server 100 . However, the present invention is not limited thereto, and the hardware accelerator may be implemented in the same device as the server 100 .
다른 실시예에서, 상기 단말기(200)는 상기 양자화된 신경망(420)을 하드웨어 가속기로 구현하지 않고, CPU 및 소프트웨어에 의해 구현할 수도 있다.In another embodiment, the terminal 200 may not implement the quantized neural network 420 as a hardware accelerator, but may be implemented by a CPU and software.
도 14는 비교 실시예에 따라 제공되는 단말기 내에서의 신경망 연산방법을 나타낸 것이다.14 is a diagram illustrating a neural network calculation method in a terminal provided according to a comparative embodiment.
도 14와 도 7을 서로 비교하면, 비교 실시예에서는 각 노드 내에 정수끼리 곱하는 연산부가 1개씩 더 포함되어 있다. 따라서 도 7의 실시예가 도 14의 실시예에 비하여 더 낮은 복잡도를 갖는다.Comparing FIGS. 14 and 7 with each other, in the comparative embodiment, each node further includes one arithmetic unit for multiplying integers. Accordingly, the embodiment of FIG. 7 has lower complexity than the embodiment of FIG. 14 .
또한, 도 14에서는 상기 1개 추가된 연산기를 위해 제공되는 추가적인 파라미터 qS 2가 더 제공되어야 한다. 즉, 서버가 단말기(200)에게 제공해야 하는 파라미터의 개수는, 도 7의 실시예보다 도 14의 실시예가 더 많다.In addition, in FIG. 14 , an additional parameter q S 2 provided for the one added operator should be further provided. That is, the number of parameters that the server should provide to the terminal 200 is greater in the embodiment of FIG. 14 than in the embodiment of FIG. 7 .
신경망에 포함된 노드들의 개수가 증가할수록 상술한 현상에 따라 도 14에 따른 신경망의 복잡도는 더 증가하며 필요한 파라미터의 양도 증가한다.As the number of nodes included in the neural network increases, the complexity of the neural network according to FIG. 14 increases according to the above-described phenomenon, and the amount of necessary parameters also increases.
이러한 측면에서 도 7에 따른 각 노드 내의 연산구조는 도 14에 따른 각 노드 내의 연산구조에 비하여 큰 장점을 갖는다. 그 결과 도 7에 따른 각 노드구조를 갖는 도 5의 신경망 역시 향상된 기술적 효과를 누릴 수 있다.In this aspect, the operation structure in each node according to FIG. 7 has a great advantage compared to the operation structure in each node according to FIG. 14 . As a result, the neural network of FIG. 5 having each node structure according to FIG. 7 can also enjoy improved technical effects.
도 14에서는 설명의 편의를 위해 노드(N31)에 적용되는 바이어스(b31)의 표시를 생략하였다. In FIG. 14 , the display of the bias b 31 applied to the node N31 is omitted for convenience of description.
본 발명의 실시예에서 사용된 곱셈기와 덧셈기를 정수형 연산기일 수 있다.The multiplier and the adder used in the embodiment of the present invention may be integer type operators.
상술한 본 발명의 실시예들을 이용하여, 본 발명의 기술 분야에 속하는 자들은 본 발명의 본질적인 특성에서 벗어나지 않는 범위 내에 다양한 변경 및 수정을 용이하게 실시할 수 있을 것이다. 특허청구범위의 각 청구항의 내용은 본 명세서를 통해 이해할 수 있는 범위 내에서 인용관계가 없는 다른 청구항에 결합될 수 있다.By using the above-described embodiments of the present invention, those skilled in the art will be able to easily implement various changes and modifications within the scope without departing from the essential characteristics of the present invention. The content of each claim in the claims may be combined with other claims without reference within the scope that can be understood through this specification.
<사사-Acknowledgement><Sasa-Acknowledgment>
본 발명은, 오픈엣지테크놀로지 주식회사(과제수행기관)가, 과학기술정보통신부와 한국연구재단 부설 정보통신기획평가원의 지원으로 이루어진 연구사업인 차세대지능형반도체기술개발(설계)-인공지능프로세서사업 중 복합감각 기반 상황예측형 모바일 인공지능 프로세서 개발(과제고유번호 2020001310, 과제번호 2020-0-01310, 연구기간 2020.04.01 ~ 2024.12.31) 연구과제를 수행하는 과정에서 개발된 것이다.The present invention is a complex of next-generation intelligent semiconductor technology development (design)-artificial intelligence processor business, a research project supported by the Ministry of Science and ICT and the Information and Communication Planning and Evaluation Institute affiliated with the National Research Foundation of Open Edge Technology Co., Ltd. (the task execution organization). It was developed in the course of carrying out the research task of developing a sensory-based situational prediction type mobile artificial intelligence processor (task unique number 2020001310, task number 2020-0-01310, research period 2020.04.01 ~ 2024.12.31).

Claims (9)

  1. 입력층, 중간층부, 및 출력층을 포함하는 정수형 신경망의 특정층의 동작을 실행하는 데이터 연산부 및 상기 데이터 연산부에게 연산용 데이터를 제공하는 내부 메모리를 포함하는 컴퓨팅 장치로서,A computing device comprising: a data operation unit that executes an operation of a specific layer of an integer type neural network including an input layer, an intermediate layer, and an output layer; and an internal memory that provides data for calculation to the data operation unit,
    상기 특정층이 상기 중간층부 또는 상기 출력층에 속한 제1층인 경우, 상기 제1층에 포함된 제1노드는,When the specific layer is the first layer belonging to the intermediate layer part or the output layer, the first node included in the first layer,
    상기 제1노드에 입력되는 한 세트의 입력 액티베이션들과 상기 한 세트의 액티베이션들에 대응하는 한 세트의 가중치들을 각각 곱하는 한 세트의 곱셈기들;a set of multipliers for multiplying a set of input activations input to the first node and a set of weights corresponding to the set of activations, respectively;
    상기 한 세트의 곱셈기의 출력들을 서로 더하는 덧셈기; 및an adder for adding the outputs of the set of multipliers to each other; and
    상기 제1노드의 출력 액티베이션을 생성하기 위하여 상기 덧셈기의 출력을 변환하여 시프트부;a shift unit converting an output of the adder to generate an output activation of the first node;
    를 포함하며,includes,
    상기 한 세트의 입력 액티베이션들 및 상기 한 세트의 가중치들 각각은 n비트의 정수형 데이터이며, 상기 시프트부는 상기 덧셈기의 출력을 n비트 우측-시프트하도록 되어 있는,wherein each of the set of input activations and the set of weights is n bits of integer data, and the shift unit is configured to right-shift the output of the adder by n bits;
    컴퓨팅 장치.computing device.
  2. 제1항에 있어서, 상기 특정층이 상기 입력층인 경우, 상기 입력층에 포함된 제2노드는, 상기 제2노드에 입력되는 실수값을 갖는 액티베이션을 소정의 입력 스케일링 팩터를 이용하여 정수값을 갖는 액티베이션으로 변환하도록 되어 있는, 컴퓨팅 장치.The method of claim 1, wherein when the specific layer is the input layer, the second node included in the input layer performs activation with a real value input to the second node as an integer value using a predetermined input scaling factor. A computing device adapted to convert to activation with
  3. 제1항에 있어서, 소정의 출력 스케일링 팩터를 이용하여 상기 출력층이 출력한 액티베이션을 변환하여 출력하는 스케일링부를 더 포함하는, 컴퓨팅 장치.The computing device of claim 1 , further comprising a scaling unit that converts and outputs the activation output from the output layer using a predetermined output scaling factor.
  4. 제3항에 있어서,4. The method of claim 3,
    상기 입력 스케일링 팩터, 상기 출력 스케일링 팩터, 및 상기 한 세트의 가중치들은 상기 컴퓨팅 장치가 다른 컴퓨팅 장치로부터 제공받은 것이며,the input scaling factor, the output scaling factor, and the set of weights are provided by the computing device from another computing device,
    상기 다른 컴퓨팅장치는,The other computing device,
    상기 정수형 신경망에 대응하는 구조를 갖는 원-신경망에 관한 정보를 이용하도록 되어 있으며,It is configured to use information about a circular neural network having a structure corresponding to the integer type neural network,
    상기 원-신경망의 입력층에 할당된 상기 입력 스케일링 팩터를 생성하도록 되어 있고,generate the input scaling factor assigned to the input layer of the neural network,
    상기 원-신경망의 출력층에 할당된 상기 출력 스케일링 팩터를 생성하도록 되어 있고,generate the output scaling factor assigned to an output layer of the neural network,
    상기 원-신경망에서 상기 입력층과 상기 출력층 사이에 정의된 중간층들 각각에 할당된 스케일링 팩터들을 생성하도록 되어 있고, generate scaling factors assigned to each of the intermediate layers defined between the input layer and the output layer in the one-neural network;
    상기 원-신경망에서 상기 제1노드에 대응하는 노드를 포함하는 제L+1층의 상류에 직결된 제L층에 할당된 제L 스케일링 팩터를 상기 제L+1층에 할당된 제L+1 스케일링 팩터로 나누어 제1값을 산출하고, 상기 제L층의 인덱스 b를 갖는 노드로부터 상기 제L+1층의 인덱스 a를 갖는 노드에 연결된 링크(linkab Layer_L)에 할당된 가중치(w.ab Layer_L)에 상기 제1값을 곱하여 제2값을 산출하고, 상기 제2값에 2n을 곱하여 제3값을 산출하고, 상기 제3값을 정수값으로 근사화하여 제4값을 생성하도록 되어 있고,In the one-neural network, the Lth scaling factor assigned to the Lth layer directly upstream of the L+1th layer including the node corresponding to the first node is the L+1th scaling factor assigned to the L+1th layer. A first value is calculated by dividing by a scaling factor, and a weight ( w.ab ) assigned to a link (link ab Layer_L ) connected from a node having an index b of the Lth layer to a node having an index a of the L+1th layer Layer_L ) is multiplied by the first value to calculate a second value, the second value is multiplied by 2 n to calculate a third value, and the third value is approximated to an integer value to generate a fourth value, ,
    상기 제4값은, 상기 가중치(w.ab Layer_L)에 대응하는 상기 정수형 신경망의 가중치(q'w.ab layer_L)인 것을 특징으로 하는,The fourth value, characterized in that the weight (q' w.ab layer_L ) of the integer type neural network corresponding to the weight ( w.ab Layer_L ),
    컴퓨팅 장치.computing device.
  5. 처리부 및 저장부를 포함하는 단말기가, 입력층, 중간층부, 및 출력층을 포함하는 정수형 신경망의 상기 중간층부 또는 상기 출력층에 포함된 제1노드의 출력 액티베이션을 생성하는 신경망 구동방법으로서,A method for driving a neural network in which a terminal including a processing unit and a storage unit generates output activation of a first node included in the intermediate layer or the output layer of an integer neural network including an input layer, an intermediate layer, and an output layer,
    상기 처리부가, 한 세트의 입력 액티베이션들을 상기 저장부로부터 획득하고, 그리고 상기 한 세트의 입력 액티베이션들에 대응하며 한 세트의 가중치들을 상기 저장부로부터 획득하는 단계;obtaining, by the processing unit, a set of input activations from the storage unit, and acquiring a set of weights corresponding to the set input activations from the storage unit;
    상기 처리부가, 상기 한 세트의 가중치들과 상기 한 세트의 입력 액티베이션들의 서로 대응하는 값들을 각각 서로 곱하여 한 세트의 제1값들을 산출하는 곱셈단계;a multiplication step in which the processing unit multiplies the one set of weights and the values corresponding to each other of the one set of input activations to calculate a set of first values;
    상기 처리부가, 상기 한 세트의 제1값들을 서로 더하여 제2값을 산출하는 덧셈단계; 및an adding step in which the processing unit adds the set of first values to each other to calculate a second value; and
    상기 처리부가, 상기 제2값을 n비트 우측-시프트함으로써 상기 제1노드의 출력 액티베이션을 산출하는 시프팅 단계;a shifting step of calculating, by the processing unit, the output activation of the first node by right-shifting the second value by n bits;
    를 포함하며,includes,
    상기 한 세트의 입력 액티베이션들 및 상기 한 세트의 가중치들 각각은 n비트의 정수형 데이터인,Each of the set of input activations and the set of weights is n-bit integer data,
    신경망 구동방법.How to run a neural network.
  6. 제5항에 있어서,6. The method of claim 5,
    상기 처리부가, 상기 입력층에 속한 제2노드에 입력되는 실수값을 갖는 액티베이션을 소정의 입력 스케일링 팩터를 이용하여 정수값을 갖는 액티베이션으로 변환하는 단계; 및converting, by the processor, an activation having a real value input to a second node belonging to the input layer into an activation having an integer value using a predetermined input scaling factor; and
    상기 처리부가, 상기 출력층이 출력한 액티베이션을 소정의 출력 스케일링 팩터를 이용하여 변환하는 단계;converting, by the processing unit, the activation output from the output layer using a predetermined output scaling factor;
    를 더 포함하는,further comprising,
    신경망 구동방법.How to run a neural network.
  7. 제5항에 있어서,6. The method of claim 5,
    상기 입력 스케일링 팩터, 상기 출력 스케일링 팩터, 및 상기 한 세트의 가중치들은 상기 단말기가 다른 컴퓨팅 장치로부터 제공받은 것이며,The input scaling factor, the output scaling factor, and the set of weights are provided by the terminal from another computing device,
    상기 다른 컴퓨팅장치는,The other computing device,
    상기 정수형 신경망에 대응하는 구조를 갖는 원-신경망에 관한 정보를 이용하도록 되어 있으며,It is configured to use information about a circular neural network having a structure corresponding to the integer type neural network,
    상기 원-신경망의 입력층에 할당된 상기 입력 스케일링 팩터를 생성하도록 되어 있고,generate the input scaling factor assigned to the input layer of the neural network,
    상기 원-신경망의 출력층에 할당된 상기 출력 스케일링 팩터를 생성하도록 되어 있고,generate the output scaling factor assigned to an output layer of the neural network,
    상기 원-신경망에서 상기 입력층과 상기 출력층 사이에 정의된 중간층들 각각에 할당된 스케일링 팩터들을 생성하도록 되어 있고, generate scaling factors assigned to each of the intermediate layers defined between the input layer and the output layer in the one-neural network;
    상기 원-신경망에서 상기 제1노드에 대응하는 노드를 포함하는 제L+1층의 상류에 직결된 제L층에 할당된 제L 스케일링 팩터를 상기 제L+1층에 할당된 제L+1 스케일링 팩터로 나누어 제1값을 산출하고, 상기 제L층의 인덱스 b를 갖는 노드로부터 상기 제L+1층의 인덱스 a를 갖는 노드에 연결된 링크(linkab Layer_L)에 할당된 가중치(w.ab Layer_L)에 상기 제1값을 곱하여 제2값을 산출하고, 상기 제2값에 2n을 곱하여 제3값을 산출하고, 상기 제3값을 정수값으로 근사화하여 제4값을 생성하도록 되어 있고,In the one-neural network, the Lth scaling factor assigned to the Lth layer directly upstream of the L+1th layer including the node corresponding to the first node is the L+1th scaling factor assigned to the L+1th layer. A first value is calculated by dividing by a scaling factor, and a weight ( w.ab ) assigned to a link (link ab Layer_L ) connected from a node having an index b of the Lth layer to a node having an index a of the L+1th layer Layer_L ) is multiplied by the first value to calculate a second value, the second value is multiplied by 2 n to calculate a third value, and the third value is approximated to an integer value to generate a fourth value, ,
    상기 제4값은, 상기 가중치(w.ab Layer_L)에 대응하는 상기 정수형 신경망의 가중치(q'w.ab layer_L)인 것을 특징으로 하는,The fourth value, characterized in that the weight (q' w.ab layer_L ) of the integer type neural network corresponding to the weight ( w.ab Layer_L ),
    신경망 구동방법.How to run a neural network.
  8. 서버가, 입력층, 중간층부, 및 출력층를 갖는 신경망의 상기 입력층에 할당된 입력 스케일링 팩터를 생성하고, 상기 출력층에 할당된 출력 스케일링 팩터를 생성하고, 그리고 상기 중간층부의 각 층에 할당된 스케일링 팩터들을 생성하는 단계; 및A server generates an input scaling factor assigned to the input layer of a neural network having an input layer, an intermediate layer part, and an output layer, generates an output scaling factor assigned to the output layer, and a scaling factor assigned to each layer of the middle layer part generating them; and
    상기 서버가, 상기 중간층부 또는 출력층에 포함된 제1노드를 포함하는 제L+1층의 상류에 직결된 제L층에 할당된 제L 스케일링 팩터를 상기 제L+1층에 할당된 제L+1 스케일링 팩터로 나누어 제1값을 산출하고, 상기 제L층의 인덱스 b를 갖는 노드로부터 상기 제L+1층의 인덱스 a를 갖는 노드에 연결된 링크(linkab Layer_L)에 할당된 가중치(w.ab Layer_L)에 상기 제1값을 곱하여 제2값을 산출하고, 상기 제2값에 2n을 곱하여 제3값을 산출하고, 상기 제3값을 정수값으로 근사화하여 제4값을 생성하는 단계;The server assigns the Lth scaling factor assigned to the Lth layer directly upstream of the L+1th layer including the first node included in the intermediate layer unit or the output layer to the Lth scaling factor assigned to the L+1th layer. A first value is calculated by dividing by a +1 scaling factor, and a weight (w) assigned to a link (link ab Layer_L ) connected from a node having an index b of the L-th layer to a node having an index a of the L+1-th layer ab Layer_L ) is multiplied by the first value to calculate a second value, the second value is multiplied by 2 n to calculate a third value, and the third value is approximated to an integer value to generate a fourth value step;
    를 포함하며,includes,
    상기 제4값은, 상기 가중치(w.ab Layer_L)에 대응하는 정수형 신경망의 가중치(q'w.ab layer_L)인 것을 특징으로 하는,The fourth value, characterized in that the weight (q' w.ab layer_L ) of the integer type neural network corresponding to the weight ( w.ab Layer_L ),
    정수형 신경망 정보처리방법.Integer type neural network information processing method.
  9. 제8항에 있어서, 상기 서버가, 상기 입력 스케일링 팩터, 상기 출력 스케일링 팩터, 및 상기 정수형 신경망의 가중치를, 상기 정수형 신경망의 동작을 실행하는 컴퓨팅 장치에게 제공하는 단계를 더 포함하는, 정수형 신경망 정보처리방법.The integer neural network information according to claim 8, further comprising the step of providing, by the server, the input scaling factor, the output scaling factor, and the weight of the integer neural network to a computing device executing the operation of the integer neural network processing method.
PCT/KR2021/014367 2020-11-03 2021-10-15 Neural network computation method and neural network weight generation method WO2022097954A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR10-2020-0145549 2020-11-03
KR1020200145549A KR102384588B1 (en) 2020-11-03 2020-11-03 Method for operating a neural network and for producing weights for the neural network

Publications (1)

Publication Number Publication Date
WO2022097954A1 true WO2022097954A1 (en) 2022-05-12

Family

ID=81183000

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2021/014367 WO2022097954A1 (en) 2020-11-03 2021-10-15 Neural network computation method and neural network weight generation method

Country Status (2)

Country Link
KR (1) KR102384588B1 (en)
WO (1) WO2022097954A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20030072860A (en) * 2002-03-07 2003-09-19 엘지전자 주식회사 Accumulation Method of Array Structure node for Pre-trained Neural Network Design
KR20190062129A (en) * 2017-11-27 2019-06-05 삼성전자주식회사 Low-power hardware acceleration method and system for convolution neural network computation
KR20190074938A (en) * 2017-12-20 2019-06-28 연세대학교 산학협력단 Digital neural, artificial neuron for artificial neuron network and inference engine having the same
JP2019185134A (en) * 2018-04-02 2019-10-24 Kddi株式会社 Information processing device, learning method, and program
KR20200061164A (en) * 2018-11-23 2020-06-02 삼성전자주식회사 Neural network device for neural network operation, operating method of neural network device and application processor comprising neural network device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20030072860A (en) * 2002-03-07 2003-09-19 엘지전자 주식회사 Accumulation Method of Array Structure node for Pre-trained Neural Network Design
KR20190062129A (en) * 2017-11-27 2019-06-05 삼성전자주식회사 Low-power hardware acceleration method and system for convolution neural network computation
KR20190074938A (en) * 2017-12-20 2019-06-28 연세대학교 산학협력단 Digital neural, artificial neuron for artificial neuron network and inference engine having the same
JP2019185134A (en) * 2018-04-02 2019-10-24 Kddi株式会社 Information processing device, learning method, and program
KR20200061164A (en) * 2018-11-23 2020-06-02 삼성전자주식회사 Neural network device for neural network operation, operating method of neural network device and application processor comprising neural network device

Also Published As

Publication number Publication date
KR102384588B1 (en) 2022-04-08

Similar Documents

Publication Publication Date Title
WO2019164251A1 (en) Method of performing learning of deep neural network and apparatus thereof
WO2021060609A1 (en) Distributed computing system comprising plurality of edges and cloud and method for providing model for adaptive intelligence usage thereof
WO2021054614A1 (en) Electronic device and method for controlling the electronic device thereof
WO2021225256A1 (en) Electronic device and control method therefor
WO2020231226A1 (en) Method of performing, by electronic device, convolution operation at certain layer in neural network, and electronic device therefor
WO2021225262A1 (en) Neural architecture search based optimized dnn model generation for execution of tasks in electronic device
WO2020040599A1 (en) Electronic device and operating method thereof of processing neural network model by using plurality of processors
WO2021153969A1 (en) Methods and systems for managing processing of neural network across heterogeneous processors
WO2020231005A1 (en) Image processing device and operation method thereof
WO2020091253A1 (en) Electronic device and method for controlling electronic device
WO2022097954A1 (en) Neural network computation method and neural network weight generation method
WO2021158085A1 (en) Neural network update method, classification method and electronic device
WO2023038414A1 (en) Information processing method, apparatus, electronic device, storage medium and program product
WO2023229094A1 (en) Method and apparatus for predicting actions
WO2023042989A1 (en) Add operation method considering data scale, hardware accelerator therefor, and computing device using same
WO2023287239A1 (en) Function optimization method and apparatus
WO2022255632A1 (en) Automatic design-creating artificial neural network device and method, using ux-bits
WO2023043108A1 (en) Method and apparatus for improving effective accuracy of neural network through architecture extension
WO2021230470A1 (en) Electronic device and control method for same
WO2021158040A1 (en) Electronic device providing utterance corresponding to context of conversation, and method of operating same
WO2021251691A1 (en) Anchor-free rpn-based object detection method
WO2022270815A1 (en) Electronic device and control method of electronic device
WO2023075372A1 (en) Method and electronic device for performing deep neural network operation
WO2021246586A1 (en) Method for accessing parameter for hardware accelerator from memory, and device using same
WO2024058572A1 (en) Multi-bit accumulator and in-memory computing processor with same

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21889419

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21889419

Country of ref document: EP

Kind code of ref document: A1