Training neural networks to perform machine learning tasks

Through the structure of sparse neural network and logic gate network, combined with binary representation and logical operators, it solves the problems of over-fitting and low computational efficiency of neural networks when performing machine learning tasks, and achieves efficient and low-resource task execution.

CN118633090APending Publication Date: 2024-09-10UNIV KONSTANZ
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202280089954.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-01-26
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing neural networks are prone to over-fitting and under-fitting problems when performing machine learning tasks, and have low computational efficiency. In particular, floating-point operation-intensive matrix multiplication operations consume a lot of hardware resources and are difficult to effectively support.

Method used

Adopt the structure of sparse neural network and logic gate network, train the neural network through the probability distribution of sparse topology and logical operators, reduce the number of parameters and improve calculation efficiency, use binary representation and logical operators to replace floating point operations, combine the softmax function and Temperature parameter optimization probability distribution.

Benefits of technology

It significantly reduces storage requirements and computing resource consumption, improves the inference efficiency and accuracy of neural networks, avoids overfitting, and enables efficient execution of machine learning tasks with lower computing costs and efficient storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118633090A
    Figure CN118633090A
Patent Text Reader

Abstract

A method, program, and system for training a neural network to perform machine learning tasks are provided. The method includes receiving input data of a neural network. The method also includes determining values of a plurality of hyper-parameters of the neural network. The method further includes constructing a neural network from the hyper-parameter values, wherein the neural network includes a plurality of neurons. Each neuron includes a probability distribution of a plurality of logical operators such that the neuron includes a respective probability of each of the logical operators. The method further includes training the neural network according to the hyper-parameter values and the input data by learning a probability distribution for each neuron. The method further includes determining a logical operator of the plurality of logical operators for each neuron by selecting a value in the probability distribution.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] The technical field is artificial intelligence, and in particular neural networks. Various aspects relate to training a neural network to perform a machine learning task. The machine learning task may be a classification task or a regression task. The classification task may include one or more of the following: pattern and / or sequence recognition, novelty detection (i.e., outlier or anomaly detection), sequential decision making. The regression task may include compression or decompression. Additionally, various aspects may relate to using a trained neural network to perform a machine learning task. Background Art

[0002] Neural networks may include artificial neurons (i.e., neurons, nodes, computational units, or cells) and may be used to solve artificial intelligence problems. Connections between neurons may be modeled as weights in a neural network. A neural network may include parameters that are components or elements of a trainable neural network. For example, weights may be parameters in some neural networks. However, other parameters are also possible.

[0003] Activation functions can be used to control the magnitude of the output of a neural network. Thus, activation functions can be used to limit the output values ​​of a neural network and add nonlinearity to the neural network.

[0004] An optimization algorithm may be used to train the neural network. Training may include adjusting the parameters of the neural network until the neural network is sufficiently accurate. The optimization algorithm may be based on (or dependent on) gradient descent. Examples of optimization algorithms based on gradient descent include Stochastic Gradient Descent (SGD) and Adam (adaptive learning rate optimization algorithm—implemented as a combination of root mean square propagation and SGD with momentum). Further information about Adam may be found in "Adam: A method for stochastic optimization" published by Kingma et al., 2014.

[0005] Gradient descent can be based on backpropagation (i.e., backprop or backward propagation). Gradient descent can include a cost function to measure the accuracy of the parameters and determine the direction in which the parameter changes improve the network, i.e., the parameters can be improved. Sufficient accuracy can be obtained when the output of the cost function is zero, minimum, or within a specified range of zero. The specified range may depend on the machine learning task. In some cases, gradient descent (or an algorithm based on gradient descent) can only be used to train neural networks with differentiable parameters, so that binary or Boolean parameters cannot be trained via gradient descent. Boolean parameters (represented as 0 or 1 in a neural network) may cause discontinuities (e.g., jumps from 0 to 1) where the gradient is undefined and gradient descent is not possible.

[0006] The accuracy of a neural network can be calculated in various ways. For example, in the case of a classification task, the training error (or loss) can be obtained by measuring how accurately the neural network can classify the data used to train the neural network. The classification loss (also called generalization error or expected loss) can be obtained by measuring how accurately the neural network can perform the classification task on previously unseen data.

[0007] In some cases, a neural network may include multiple layers, i.e., at least one hidden layer and an output layer. In this case, the neural network may be referred to as a deep learning neural network, and there may be an unbounded number of hidden layers. Thus, multiple layers may be used to gradually extract higher-level features from the input. The neural network may be implemented as a feedforward network, in which data flows from the previous hidden layer to the output layer without looping back. Initialization of the neural network may include assigning random weights to connections between neurons.

[0008] Typically, if a neural network is not performing the machine learning task accurately, the weights are adjusted. In this way, the influence of different neurons in the network can be calibrated until the appropriate mathematical operation for the input to perform the machine learning task is determined.

[0009] Once trained to perform a machine learning task, a neural network can be used to perform a machine learning task. Performing a machine learning task can also be referred to as inference or performing inference.

[0010] Neural networks face various problems. For example, overfitting can occur when the training error is low but the classification loss is relatively high. In other words, the neural network learns methods specific to the training data used to train the neural network, which does not generalize well to other data different from the training data. Underfitting can occur if the neural network does not accurately capture the relationship between its input and its output, generating high error rates on both the training data and other data.

[0011] Although neural networks can be effective at performing classification tasks, they can be inefficient. Therefore, various methods have been developed to improve the efficiency of neural networks.

[0012] For example, a conventional neural network may be a deep learning neural network that includes at least one dense layer, such that some or all of the neural network is fully connected; that is, each neuron in a dense layer receives input from all neurons in the previous layer. In this example, the neural network may be referred to as a densely connected neural network or a fully connected neural network.

[0013] In addition, conventional neural networks may employ floating point calculations with full precision weights and activations (e.g., double precision, i.e., 64-bit), and typically require expensive matrix multiplications. Even if lower precision floating point weights and activations (e.g., single precision or half precision) are used, the calculations may still be expensive.

[0014] Binary neural networks may differ from conventional neural networks in that 1-bit activations (and / or weights) replace the floating point activations (and / or weights) of conventional neural networks. Thus, elements propagated through the network are binary, meaning that they may have only one of two values, e.g., 0 or 1. Thus, expensive matrix multiplications compared to conventional neural networks may be reduced to faster XNOR and bit counting operations, which greatly improves the inference performance of binary neural networks compared to conventional neural networks. In some cases, XNOR may be faster than bit counting operations, and both may be faster than floating point operations.

[0015] The floating point operations required for training neural networks can be supported in the hardware of the computer. Specifically, a floating point 32-bit adder and / or a floating point 32-bit multiplier may require at least 1000 logic gates (or lookup tables) and may have a delay of tens of logic levels. A floating point 32-bit adder and / or a floating point 32-bit multiplier can be implemented directly in a central processing unit (CPU) or a graphics processing unit (GPU). However, compared to the bitwise logic operations on integer 64-bit data types, even on GPUs optimized for floating point 32-bit and integer 32-bit data types, floating point 32-bit adders and floating point 32-bit multipliers may require more computing resources (e.g., processing cycles). When optimizing GPUs for integer 32 bits, it may not be possible to effectively support integer 64 bits. Therefore, it may be more effective to use integer (int) 32-bit data types on such GPUs. In some hardware implementations, logical operations may be faster than addition and / or multiplication operations.

[0016] On a CPU, approximately 3 to approximately 10 integer 64-bit operations can be performed for each clock cycle, while floating-point operations typically require a full clock cycle (i.e., only one floating-point operation can be performed per clock cycle). Therefore, XNOR and bit-counting operations performed when training binary neural networks can have significant performance advantages over floating-point operations performed for conventional neural networks, even when floating-point operations (e.g., floating-point 32-bit adders or floating-point 32-bit multipliers) have dedicated hardware support in a GPU or CPU. Considerations regarding floating-point and integer operations may also apply to training neural networks for machine learning tasks.

[0017] A convolutional neural network (CNN) may be a deep learning neural network in which at least one hidden layer has structured connections, i.e., is not fully connected. Thus, a CNN may perform a convolution, e.g., a hidden layer performs a dot product of a convolution kernel with an input matrix of the hidden layer. Thus, only neurons of the hidden layer covered by the convolution kernel may be connected to corresponding neurons of another layer in the CNN. Summary of the invention

[0018] In a conventional example, the binary neural network can be based on a very deep convolutional neural network (e.g., VGG) architecture that increases depth via very small (3×3) convolutional filters, includes three fully connected layers, and uses rectified nonlinearity (ReLU) to cut training time. Alternatively, the binary neural network can be based on a residual neural network (ResNet) architecture that uses skip connections to skip some layers. Both VGG and ResNet architectures can result in very large neural networks, which can lead to inefficiencies.

[0019] A neural network can be sparse (in this example, a sparse neural network). Thus, a sparse neural network has a suitable subset of the connections of a fully connected neural network. In other words, rather than a fully connected layer, not all neurons in a layer of a sparse neural network are connected to each other. Sparsity can refer to the connectivity of a neural network, such that each neuron receives input from only a limited number of other neurons, and / or to the state of a neural network, which describes the activity level of all neurons in the neural network, such that not all neurons in a sparse neural network are active at any given time.

[0020] A sparse neural network may have less than 90% of the connections of a fully connected neural network, i.e., a sparse neural network may have a sparsity of at least 10% (sparsities between 10% and 70% may be referred to as low sparsity, sparsities between 70% and 90% may be referred to as medium sparsity, sparsities between 90% and 99.9% may be referred to as moderate sparsity, and sparsities above 99.9% may be referred to as high sparsity). A neural network with a sparsity of less than 10% may be referred to as dense.

[0021] Sparse neural networks can be derived from dense or fully connected neural networks using pruning or compression techniques (e.g., regularization techniques). For example, one or more analytical methods or heuristics can be used to determine the weights to be retained and the weights to be removed from the neural network (removing weights may include setting the weights to 0). More specifically, L1 or L2 regularization can be used to update the general cost function by adding regularization terms. As another example, dropout is a regularization technique in which random neurons in a neural network are eliminated or removed. Dropout can be variable and can be limited by a boundary (e.g., a limit on how many neurons are eliminated). In some cases, neurons themselves can be removed from the neural network instead of removing weights. As described above, pruning techniques can help avoid overfitting, thereby reducing generalization errors. Other techniques may include removing entire layers of a neural network or adding additional costs for relatively large weights of a neural network. Therefore, sparse neural networks can provide improved accuracy (e.g., less overfitting) compared to dense neural networks. Sparse neural networks may also require less storage space compared to dense neural networks. However, in the case where a sparse neural network is derived by removing weights from a dense neural network, the sparse neural network may require more storage in order to store the weight positions in addition to the actual weights.

[0022] In the following two examples of conventional implementations, the connectivity of a neural network may be relaxed.

[0023] In a first example, the neurons of a neural network may be implemented as logic modules, where half of the logic modules are defined as fuzzy (i.e., relaxed) connections and the other half are defined as fuzzy (i.e., relaxed) separations. In this example, the parameters of the neural network include weights, while the operators (i.e., fuzzy connections and separations) are fixed. Thus, the weights of the neurons included in the fuzzy connections and separations may be relaxed from just 0 or 1 to values ​​in the range of 0 to 1. In this way, the parameters of the logic modules may be trained via gradient descent, unlike Boolean parameters.

[0024] In the second example, a set of arithmetic operations is predefined for each layer and implemented for the neurons of that layer. A form of Sofmax is used for learning, and the output of the previous layer is used as the input of the arithmetic operation corresponding to the current layer. In this way, symbolic expressions can be learned from data.

[0025] In another conventional example, before training, fully connected layers of an artificial neural network are replaced with sparse layers to reduce the number of parameters quadratically without significantly reducing accuracy (e.g., without reducing accuracy by more than 5% or more than 10%). The sparse topology has two consecutive layers and is evolved into a scale-free topology during training. The scale-free topology is an approximate power-law degree distribution P(d)~d -y , where a fraction P(d) of the total neurons in the network have d connections to other neurons, and the parameter γ is typically kept in the range of γ∈(2,3).

[0026] In yet another conventional example, a single shared weight parameter is assigned to each connection in a neural network. Instead of optimizing weights, the neural network is optimized for a network topology that performs well over a wide range of weights. Neurons and connections are added incrementally, and activation functions (e.g., sine, cosine, Gaussian, hyperbolic tangent, sigmoid, inverse, absolute value, ReLU) are randomly assigned to new neurons. The activation function evolves as the neural network grows. The neural network uses floating point arithmetic.

[0027] According to another conventional example, a method for storing a binary classification data set using a network of binary (2-input) lookup tables is provided. The network of lookup tables is constructed by counting the conditional frequencies in the training data (e.g., how many times a pattern p is associated with a particular output 0 in the training data). As with neural networks, the lookup tables are arranged in consecutive layers. Unlike neural networks, training occurs via memorization and does not involve back propagation or gradient descent. Memorization involves remembering the outputs that are most commonly associated with the inputs in the training data.

[0028] In another common example, a neural network is first trained on a machine learning task, the neural network is then converted to a random forest, and then the random forest is converted to a network of AND inverter logic gates, i.e., the network is based on "AND" and "NOT" logic gates.

[0029] It is desirable to provide a neural network for performing machine learning tasks that is more efficient than the conventional examples described above while maintaining comparable accuracy.

[0030] For example, a network of logic gates may be used. The network of logic gates may be a neural network in which each neuron includes a logic operator (i.e., a logic gate such as an "AND" or "NAND"). Each logic operator may have an input between 0 and 2. The network of logic gates is sparse compared to a fully connected neural network in which all neurons of the previous layer are provided as inputs to each neuron of the current layer. In other words, the network of logic gates is sparse because, instead of receiving n inputs, where n is the number of neurons in each layer, each neuron of the network of logic gates receives only two inputs. Therefore, machine learning tasks may be performed efficiently because logic operations may be calculated very quickly (e.g., because logic operations are often embedded in the architecture of the processor). In addition, because each neuron has at most two inputs, the network of logic gates is very sparse, e.g., at least medium sparsity, which may result in improved accuracy compared to denser networks.

[0031] Optionally, the logic gate network may include at least one operator having 3 or more inputs.

[0032] Advantageously, logic gate networks may not require activation functions because they can operate on binary values ​​(eg, after training) and are non-linear.

[0033] However, implementing a neural network as a network of logic gates can be problematic because conventional logic gate networks cannot be trained using gradient descent-based optimization algorithms, such as SGD or Adam (described above). This is because the values ​​in a conventional logic gate network will always be either 0 or 1. Therefore, it is not possible to compute gradients in a conventional logic gate network because there are no derivatives of the loss function with respect to the parameters of the network layers. Therefore, it may be desirable to provide a logic gate network that can be trained using a gradient descent-based optimization algorithm.

[0034] In addition, conventional logic gate networks can provide a single binary output (e.g., for regression tasks) or k binary outputs for k classes (e.g., for classification tasks). This does not allow hierarchical prediction, i.e., rating classes relative to each other. In other words, this does not allow classification according to a "maximum activation" classification scheme ("How a Neural Network Works", Arkin Gupta, May 27, 2018).

[0035] According to one aspect, a computer-implemented method for training a neural network to perform a machine learning task is provided. The method includes receiving input data for the neural network. The method also includes determining values ​​for a plurality of hyperparameters for the neural network. The method also includes constructing a neural network based on the hyperparameter values, wherein the neural network includes a plurality of neurons. Each neuron includes a probability distribution for a plurality of logical operators, such that the neuron includes a corresponding probability for each logical operator. The method also includes training the neural network based on the hyperparameter values ​​and the input data by learning the probability distribution for each neuron. The method also includes determining a logical operator from a plurality of logical operators for each neuron by selecting a value from the probability distribution.

[0036] Neural networks may be referred to as binary neural networks (because once the neural network is trained, the elements propagating in the network can only have one of two values), logic gate networks (because neurons implement logic operators), or binary logic gate networks. Logic operators may be referred to as logic gates.

[0037] In some cases, each neuron has at most two inputs. When there are exactly two inputs per neuron and there are n neurons per layer, the neural network can have a sparsity of at most 1–(2 / n).

[0038] The values ​​of multiple hyperparameters can be determined based on received hyperparameters (e.g., used to perform similar machine learning tasks or used by similar neural networks to perform the same machine learning task), or can be defined without receiving initial values.

[0039] In some cases, the probability distribution for each neuron may be a categorical probability distribution derived from a plurality of floating point values ​​such that all entries in the probability distribution sum to 1 and are non-negative. The probability distribution may be derived from the floating point values ​​via a softmax such that the floating point values ​​are mapped to a probability simplex, resulting in a categorical probability distribution. Since the probability distribution is trained, the probability distribution of the neural network may also be referred to as the parameters of the neural network.

[0040] The probability of a probability distribution can be ≥0 and ≤1.

[0041] Softmax can be a general function for converting values ​​to probabilities. Softmax can include temperature (i.e., a temperature parameter), where temperature can increase sensitivity to low probabilities. In other words, temperature can be a way to control the entropy of a probability distribution (high temperatures increase entropy, making the probability distribution more uniform, while low temperatures reduce entropy and emphasize higher probabilities).

[0042] Selecting a value in a probability distribution can be accomplished by selecting the most likely value or selecting a random value. More specifically, selecting a value can involve repeatedly selecting a random value until an appropriate value is found. In some cases, the selection can include replacing the probability distribution with a mode of the probability distribution. Thus, in a trained neural network, the input and output of each neuron can be Boolean (0 or 1) and / or the operator of each neuron can be fixed (i.e., a single operator rather than a probability distribution).

[0043] Therefore, the logic gate network can be trained by learning the probability distribution of each neuron, because the use of the probability distribution enables the calculation of the gradient that can be used to minimize the loss function. Therefore, compared with the conventional logic gate network described above, the derivative of the loss function can be calculated, and the gradient vector can be obtained. The derivative of the loss function is the direction in which the neural network improves. Therefore, being able to calculate the derivative of the loss function enables the neural network to be improved during training.

[0044] The input data may include inputs and corresponding expected outputs. The input data may include training data, validation data, and test data. The training data, validation data, and test data may be mutually exclusive or disjoint. In other words, samples in the training data do not appear in the validation data or the test data, and samples in the test data do not appear in the validation data or the training data. In this way, overfitting may be determined when hyperparameters are evaluated using validation data and when the accuracy of the neural network is tested using test data. In some cases, it may be desirable to avoid overfitting. In other cases (sometimes referred to as benign overfitting), the neural network may still be relatively accurate relative to the validation and test data even when approximately 100% accuracy is achieved on the training data. Samples may also be referred to as data points.

[0045] In some cases, the training data can be used to train the neural network according to the determined hyperparameter values. The validation data can be used to compare the determined set of hyperparameter values ​​to another determined set of hyperparameter values. Once the final (e.g., most accurate) value for the hyperparameter is determined, the test data can be used to determine the accuracy of the neural network when performing a machine learning task.

[0046] The desired output may be referred to as a label. The input data may be provided as a set of tuples, where each tuple has the following form: (input or sample, corresponding output). The samples may be provided as fixed-size vectors (e.g., binary vectors), or may have a known topology (e.g., an image).

[0047] In some cases, hyperparameter values ​​may be determined to minimize a validation error of the neural network under one or more specified computing resource constraints, which may include processor and / or memory constraints.

[0048] There may be at least 5 hyperparameters or at least 10 hyperparameters. The hyperparameter values ​​may determine the structure of the neural network and how the neural network is trained. The hyperparameters may affect the computational time and memory cost of inference performed via the neural network. In addition, the hyperparameters may affect the accuracy of the neural network. For example, too many neurons per layer may result in overfitting, while too few layers or neurons per layer may result in underfitting.

[0049] In some cases, multiple sets of hyperparameter values ​​may be determined, and a neural network may be trained based on each set of hyperparameter values. If sufficiently accurate, the most accurate of the trained neural networks may be used for inference.

[0050] Hyperparameter values ​​(values ​​for multiple hyperparameters) may be randomly selected via an optimization algorithm (e.g., grid search or automatic machine learning - AutoML) or via random search. The optimization algorithm may be implemented using constraints provided by the user. The constraints may depend on the machine learning task. In the context of grid search, the constraints may be referred to as a grid. Grid search may be performed via a conventional grid search algorithm.

[0051] In some cases, the input data may include training data and validation data. Thus, for each of a plurality of sets of hyperparameter values, the neural network may be trained using the training data and the set of hyperparameter values, and then the accuracy of the neural network may be validated using the set of hyperparameter values ​​and the validation data. The set of hyperparameter values ​​that has the lowest error with the validation data (i.e., the lowest validation error and the most accurate hyperparameter value) may be the determined hyperparameter value.

[0052] Hyperparameters may include one or more of the following: number of neurons per layer, number of layers, number of epochs, batch size, learning rate. In the context of classification tasks, hyperparameters may further include a softmax temperature for training probability distributions. As the number of neurons per layer increases, the softmax temperature may be used to increase. Thus, the softmax temperature may depend on the number of outputs per class (e.g., the softmax temperature may increase as the number of outputs per class increases).

[0053] The number of neurons in each layer of the neural network can be determined according to the following constraints (e.g., selected from the following grid): {100, 1000, 10,000, 100,000, 1,000,000, 10,000,000}. The number of layers in the neural network can be determined according to the following constraints (e.g., selected from the following grid): {4, 5, 6, 7, 8}. Alternatively, a grid of {2, 3, 4, 5, 6, 7, 8, 9} can be used. For certain machine learning tasks, such as classification tasks involving tabular data, a neural network with a smaller number of neurons may perform better. In this case, fewer neurons can help avoid overfitting. Conversely, more neurons (e.g., 64,000) may be better for image classification.

[0054] The softmax temperature may be determined according to the following constraints (e.g., selected from the following grid): {1, 3, 10, 30, 100}. Alternatively, a grid of {1, 1 / 0.3, 1 / 0.1, 1 / 0.03, 1 / 0.01} may be used. As the number of neurons per layer increases, an increase in the softmax temperature may improve performance. For example, if the number of neurons per layer is 2000 to 10,000, a softmax temperature of approximately 10 may result in an accurate neural network (low validation error) compared to other softmax temperature values. If the number of neurons per layer is 12,000 to 100,000, a softmax temperature of approximately 30 may result in an accurate neural network. If the number of neurons per layer is greater than 100,000, a softmax temperature of approximately 100 may result in an accurate neural network. If the number of neurons per layer is 100, a softmax temperature less than 3 (e.g., 1 or 3) may result in an accurate neural network.

[0055] Training the neural network according to the hyperparameter values ​​may include training a number of epochs at a batch size having a learning rate.

[0056] The number of epochs can be the number of times all training data is presented to the neural network (e.g., provided as input to the neural network) while training. For example, when determining hyperparameters, the number of epochs can be increased until the validation error begins to increase even when the training error decreases (overfitting). A suitable value for the number of epochs can be approximately 200.

[0057] Batch size may refer to the number of samples (i.e., instances, observations, input vectors, or feature vectors) from input data that are propagated through a neural network for each training iteration. For example, in the context of a classification task of image classification, each sample of input data may include an image and a label for the image. Possible values ​​for batch size may be 32, 64, 128, 256, and other powers of 2. In some cases, a batch size of about 100 may be used.

[0058] The learning rate may specify how much to change the neural network in response to the validation error at each epoch. When setting the learning rate, there may be a tradeoff between convergence rate and low validation error and increasing training error during training. The learning rate may be determined according to the following constraints (e.g., selected from the following grid): {0.1, 0.01, 10 -3 , 10 -4 , 10 -5}. For example, a learning rate of about 0.01 may be used.

[0059] Training a neural network may include continuously parameterizing a probability distribution. Thus, the probability distribution for each neuron may be parameterized during training (e.g., using softmax to independently select elements from a standard normal distribution). For example, an outcome may be calculated from each probability distribution in the neural network, e.g., the outcome may be calculated during each epoch (i.e., each stage of learning). The outcome may be an average, a weighted average, or another statistical function of the probability distributions.

[0060] The neural network may include a plurality of layers including an output layer. The neural network may include at least one hidden layer. At least one layer (e.g., a hidden layer) may precede the output layer. An input of the neural network may be accessed by a first layer, e.g., a first layer of the plurality of hidden layers.

[0061] In the case of multiple hidden layers, each hidden layer may have the same number of neurons.

[0062] The neural network may have the same number of neurons in the hidden layer and the output layer. Additionally or alternatively, the neural network may have 4 to 8 layers.

[0063] When the machine learning task is a classification task, the classification task may have at least two categories. In some cases, the number of neurons in each layer may be selected so that each class of the classification task is associated with multiple neurons in the output layer. Thus, by using multiple neurons per class and aggregating them by summing, a hierarchical classification may be performed, with as many levels (levels) as there are neurons per class. Each neuron in a class may capture different evidence (or aspects) of the class, thereby allowing a more refined hierarchical classification than conventional logic gate networks.

[0064] The method may further include: after determining the logical operator for each neuron, performing the machine learning task using the trained neural network. In the case of a classification task, the output layer may include n neurons, and the classification task may have k categories. Therefore, performing the classification task using the trained neural network may include:

[0065] The trained neural network outputs the classification score for each category.

[0066] Group the output into k groups of size n / k, where the number of 1s in each group corresponds to the classification score of the class corresponding to that group,

[0067] Determining a classification includes determining a maximum value for the classification scores.

[0068] Determining the maximum value of the classification score may include using an argmax operation to determine the class with the maximum probability (ie, the maximum predicted probability). Thus, an argmax operation may be used to determine the maximum value of the classification score.

[0069] In some cases, the output bits of each class (i.e., for each classification score) can be aggregated into a binary number to reduce the required memory bandwidth for returning the prediction (i.e., the classification score). This can be represented via a fixed network of logic gates. Specifically, an adder can be implemented, which can add one bit to a binary number using logic gates. Therefore, an adder can be implemented for each classification score so that the number of adders corresponds to the number of classification scores. The adders can be modified so that they are suitable for adding the output bits of the corresponding categories into integers. In this way, the aggregation is very efficient, and specifically, the aggregation is faster than storing the unaggregated results in VRAM.

[0070] After determining the logical operator for each neuron and before outputting the classification score, the method may further include: converting the trained neural network into a binary executable on a central processing unit (CPU) or a graphics processing unit (GPU). In some cases, the executable binary may be called via a program such as Python that can process a shared object binary. The binary executable on the CPU may be compiled from C code. The binary executable on the GPU may be compiled from CUDA (formerly Compute Unified Device Architecture).

[0071] The inputs and outputs of neurons can be real-valued.

[0072] In some cases, during training, the output of all neurons may be a value in the range of 0 to 1 (i.e., greater than or equal to 0 and less than or equal to 1). Similarly, the input of a neuron may be greater than or equal to 0 and less than or equal to 1. Additionally or alternatively, each neuron may receive between 0 and 3 inputs. More specifically, each neuron may receive between 0 and 2 inputs. For example, a "0" operator may receive 0 inputs, an "A" operator may receive only 1 input, and an "A-AB" operator may receive 2 inputs.

[0073] Building the neural network may also include pseudo-randomly initializing connections between neurons (i.e., weights of the neural network). Pseudo-random initialization may have the advantage that connections do not need to be stored but may be generated as needed. In particular, connections may be generated from a seed (i.e., a random seed used to initialize a pseudo-random number generator) and reproduced from the same seed. The seed may be generated from the state of a computer (e.g., time) or from a dedicated hardware-based random number generator. Building the neural network may also include using other heuristics to initialize connections, for example, pseudo-randomly initializing connections within a group, or including structures that allow for faster computation on dedicated hardware.

[0074] Thus, once the neural network is trained, storing the neural network requires only storing four bits of information that specify which logical operator is used for each neuron. In other words, storing the neural network may require n×4 bits (where n is the number of neurons in the neural network), plus a relatively low constant value. The constant value may include (e.g., may be limited to) the seed and the size of the layer (the number of inputs and the number of outputs). When the layers are the same size (i.e., all layers have the same size), then only one size value is required. In this way, the storage requirements of the neural network can be significantly lower than conventional neural networks (e.g., dense neural networks, convolutional neural networks, sparse neural networks, or even binary neural networks).

[0075] During training, the connections between neurons may remain fixed. In other words, the neural network may not be trained by adjusting the weights of the neurons.

[0076] Classification tasks may include one or more of the following: binary classification, pattern recognition (e.g., feature classification), image classification, object identification or recognition, character recognition, gesture or facial recognition, speech detection or speech recognition, text classification.

[0077] For example, input data for a binary classification task may include binary vectors of size 17. Each binary vector may be classified as either class 0 or class 1. In another example, input data for a pattern recognition (specifically, image classification) task may include images of digits from 0 to 9 and corresponding labels for each image. Each image may be classified by identifying which digit the image corresponds to.

[0078] Binary classification may include one of: medical testing (determining whether a patient has a disease), quality control (determining whether technical specifications have been met), and information retrieval (determining whether a page should be in the result set of a search).

[0079] Pattern recognition may include image processing (e.g., image classification). Pattern recognition may be used for one of the following: identification and / or authentication, medical diagnosis, defense, and mobility. Identification and / or authentication may include license plate recognition, fingerprint analysis, facial recognition, voice-based authentication. Medical diagnosis may include screening for cervical cancer, breast tumors, or heart sounds. Defense may include navigation and guidance systems, target recognition systems, shape recognition technology. Mobility may include driver assistance systems (to assist in driving and parking) and / or autonomous vehicle technology (for ground vehicles that can move safely with little or no human input).

[0080] The machine learning task may be a regression task, wherein the regression task may include one or more of the following: generating an image, generating text, generating a video, generating speech, 3D reconstruction, compression, encoding. In particular, the regression task may include video, audio or image compression. Encoding may include speech encoding.

[0081] Training the neural network may also include determining whether the neural network is sufficiently accurate by comparing the accuracy of the neural network to a specified accuracy. Training is performed in a differentiable manner, i.e., the probability distribution of logical operators for neurons in the neural network is learned during training. Thus, training includes determining the loss or error of the probability distribution of neurons. In contrast to training, inference (i.e., using the trained neural network) does not need to be differentiable and may be performed using fixed logical operators and hard (0 or 1) values ​​rather than relaxed (probability from 0 to 1) values.

[0082] The accuracy of a neural network can be conventionally determined using a conventional loss function. For example, a softmax cross entropy classification loss function can be used. In this context, cross entropy is a measure of the divergence of the difference between two probability distributions. Alternatively, mean squared error loss can be used for regression.

[0083] The specified accuracy may be determined according to the machine learning task. For example, the specified accuracy for binary classification may be approximately 100%, while the specified accuracy for image classification may be at least 95% or at least 97%.

[0084] Training the neural network may further include determining new values ​​for hyperparameters when the neural network is not accurate enough. The new values ​​for the hyperparameters may be determined iteratively, for example, using Bayesian optimization. Thus, the neural network may be rebuilt according to the new values, and the rebuilt neural network may be trained according to the new values. After performing a specified number of iterations (or when a specified accuracy is reached), a most accurate neural network may be determined based on the neural network and the rebuilt neural network. The most accurate neural network may be provided as the trained neural network.

[0085] There may be a tradeoff between accuracy and efficiency. In particular, a neural network that includes more neurons may be less effective in inference. Therefore, for efficiency reasons, it may be desirable to reduce the specified accuracy. In addition, knowledge from previous iterations can be used to determine new hyperparameter values ​​for subsequent iterations. For example, the constraints used to determine the hyperparameter values ​​can be modified.

[0086] In some examples, the plurality of logical operators may include at least 2 operators, at least 8 operators, or exactly 16 operators.

[0087] In some examples, a number of logical operators may be real-valued (ie, relaxed counterparts of logic gates).

[0088] The logical operators may conform to one of the following interpretations: probability, Hamacher t-norm, relativisticEinstein and t-conorm, Lukasiewicz t-norm, and t-conorm.

[0089] Real-valued logical operators can be derived from fuzzy logic.

[0090] The t-norm may be a binary operation used in fuzzy logic to represent connections. Similarly, the t-conorm may be used to represent separation in fuzzy logic.

[0091] The use of real-valued logic operators and / or real-valued inputs can help make the neural network differentiable. Conventional logic gate networks are not differentiable because their parameters are restricted to 0 and 1. The use of real values ​​can enable the calculation of gradients as derivatives (e.g., multi-dimensional derivatives) of the loss function with respect to the network parameters because the use of real values ​​eliminates discontinuities, such as jumps from 0 to 1. Therefore, the neural network can be referred to as a differentiable logic gate network. Making the neural network differentiable can facilitate training using gradient descent-based algorithms.

[0092] Additionally, the inputs and outputs of neurons may be real-valued during training, but may be Boolean (fixed) in the trained neural network. Similarly, the logical operators of the trained neural network may be discretized by taking their patterns so that each probability distribution is replaced by the logical operator with the highest value in the probability distribution.

[0093] Real-valued logical operators may include the following:

[0094] 0, A·B, A-AB, A,

[0095] B-AB, B, A+B-2AB, A+B-AB,

[0096] 1-(A+B-AB), 1-(A+B-2AB), 1-B, 1-B+AB,

[0097] 1-A, 1-A+AB, 1-AB, 1.

[0098] In real-valued logic, the operators above A and B may be inputs from the corresponding neurons. In other words, the real-valued logic operator for a given neuron may perform an operation on input A from a first neuron and input B from a second neuron. In the case of 0 and 1, these values ​​may be output regardless of the inputs. The real-valued logic operators above may correspond to probabilistic interpretations (i.e., probability product T-norm and probability sum T-conorm). However, other interpretations (as described above) may also be used.

[0099] In some cases, the input data may include test data having a plurality of samples. The method may further include, during inference (i.e., after training), performing the machine learning task by accessing, by a first layer of the neural network, the aggregation of the test data, the accessing including assigning elements of each sample of the test data to consecutive bits of an integer. Thus, during inference (i.e., after training), the two inputs to each neuron have digital data types corresponding to data types implemented by hardware of a processor of a computer on which the machine learning task is performed.

[0100] Thus, the aggregation of test data may have an aggregation size, i.e., the aggregation size of a batch during inference. The aggregation size corresponds to the data type implemented by the hardware of the processor (i.e., the assembly language data type), and is therefore valid. For example, an aggregation size of 64 may be used for an integer 64 hardware implemented data type, while an aggregation size of 32 may be used for an integer 32 hardware implemented data type.

[0101] Specifically, the sample of the test data may be an image, and the elements of the sample may be pixels of the image. The digital data type may be an integer data type, such as int64, rather than a Boolean data type conventionally used with binary neural networks. Therefore, each neuron input may be a portion of an integer64 integer, such that the entire integer consists of 64 different neuron inputs. The cluster size may be 64. Therefore, each batch of images provided for the machine learning task may include 64 images, each image having 784 binary pixels (i.e., 28×28 bitmap images), so that the images can be batched (i.e., spread) into an array of 784 integer variables, each of which has a hardware-implemented data type int64. The processor of the computer on which the machine learning task is performed may be a CPU or a GPU.

[0102] Accessing the test data through the neurons of the first layer may correspond to spreading the test data over the neurons of the first layer. Accessing may include assigning (all) values ​​of image 1 to bit 1 of an integer, and assigning (all) values ​​of image 2 to bit 2 of an integer, such that each consecutive image is spread over all integers of the first layer. In other words, Boolean value i of image k may be assigned to bit k of integer64 value i.

[0103] Therefore, all logical operations are performed on integers, since these operations are the same for each image. Therefore, bitwise operators can be applied to the 64 bits of the integer type 64 at the same time, usually with the same (or comparable) processing cost as applying bitwise operators to a single value with a Boolean data type.

[0104] In this way, performance can be significantly improved compared to the performance of operating on values ​​having a Boolean data type. In particular, this performance improvement relies on the fact that on many processors (e.g., many if not most CPUs), performing bitwise operations on values ​​having a Boolean data type and values ​​having an integer data type corresponding to a data type implemented by the processor's hardware (e.g., an int64 data type) effectively takes the same amount of time, i.e., it requires one instruction. Further efficiencies can be achieved by using data types larger than int64, such as using the Advanced Vector Extensions (e.g., AVX, AVX2, AVX-512) instruction set.

[0105] As an alternative to CPU or GPU, dedicated hardware such as ASIC or FPGA can be used. In this case, the Boolean data type can be used effectively.

[0106] According to another aspect, a computer program is provided. The computer program includes instructions that, when the program is executed by a computer, cause the computer to perform a method as described above. The computer program may be part of (or included in) a computer program product. The computer program may be (tangibly) included in a computer readable medium. The computer program may be implemented in hardware or software. In particular, the computer program may be implemented using an FPGA or ASIC. Additionally or alternatively, the computer program may be implemented in a processor (CPU or GPU) component that includes hardware encoding (e.g., an FPGA or ASIC) that implements a neural network to perform a specified task.

[0107] According to yet another aspect, a computer system for training a neural network to perform a machine learning task is provided. The computer system includes at least one processor. The processor is configured to receive input data for the neural network, determine values ​​of multiple hyperparameters for the neural network, and construct the neural network based on the hyperparameter values. The neural network includes multiple neurons. Each neuron includes a probability distribution for multiple logical operators, so that the neuron includes a corresponding probability for each logical operator. The processor is also configured to train the neural network based on the hyperparameter values ​​and the input data by learning the probability distribution of each neuron. The processor is also configured to determine a logical operator from a plurality of logical operators for each neuron by selecting a value from the probability distribution.

[0108] The processor may be a GPU that includes features that may be used to accelerate the training of a neural network to perform a machine learning task (using the techniques of this disclosure) or to accelerate the execution of a machine learning task.

[0109] Additionally or alternatively, the computer system may be implemented using at least one FPGA and / or ASIC.

[0110] Additionally or alternatively, the computer system may include hardware acceleration (eg, in an ASIC) for the logic gate network.

[0111] The subject matter described in the present disclosure may be implemented as a method or on a device, and may be implemented in the form of one or more computer programs (eg, computer program products). Such computer programs may enable a data processing device to perform one or more operations described in the present disclosure.

[0112] The subject matter described in the present disclosure may be implemented in a data signal or on a machine-readable medium, wherein the medium is contained in one or more information carriers, such as a magnetic tape, a CD-ROM, a DVD-ROM, a semiconductor memory or a hard disk. In particular, the disclosed subject matter may be tangibly contained in a machine (computer) readable medium.

[0113] In addition, the subject matter described in the present disclosure may be implemented as a system including at least one processor and a memory connected to the processor. The processor may be a central processing unit (CPU) or a graphics processing unit (GPU). The memory may encode one or more programs so that the processor executes one or more methods described in the present application. Other subjects described in the present disclosure may be implemented using various machines. The CPU and / or GPU may include an integrated circuit with hardware acceleration (e.g., hardware acceleration for floating point arithmetic). Alternatively, the processor may be general hardware without hardware acceleration (e.g., floating point acceleration).

[0114] In addition, the subject matter of the present disclosure may be implemented on at least one field programmable gate array (FPGA). FPGAs may be specifically designed for artificial intelligence, and / or specifically for implementing neural networks. FPGAs may be configurable hardware acceleration processors that can efficiently perform a predetermined task (or set of tasks) when the predetermined task is expressed via logic gates. FPGAs may be particularly suitable for tasks of limited complexity when high speed is required, such as mining cryptocurrency (e.g., Bitcoin) or implementing an oscilloscope. Therefore, for operations on neural networks, FPGAs specifically designed to process neural networks may be 10 to 100 times faster than conventional CPUs.

[0115] Additionally or alternatively, the subject matter of the present disclosure may be implemented using an application specific integrated circuit (ASIC) customized for a specific use. For example, an ASIC may be developed to support artificial intelligence. Specifically, Google's Tensor Processing Unit or Fujitsu's Deep Learning Unit may be used.

[0116] Additionally or alternatively, a hardware implementation of a logic gate network may be used. Specifically, an FPGA or ASIC may be used to implement the logic gate network, or a GPU may include features that can be used to accelerate the training of a neural network to perform a machine learning task (using the techniques of the present disclosure) or to accelerate the execution of a machine learning task.

[0117] The details of one or more implementations are set forth in the exemplary drawings and description that follow.Other features will be apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS

[0118] Figure 1 A simplified neural network comprising an input, two hidden layers, and an output layer is shown.

[0119] Figure 2 Another simplified neural network is shown.

[0120] Figure 3 The steps of a method for training a neural network to perform a machine learning task are shown.

[0121] Figure 4 shows the distribution of logical operators in a four-layer neural network after training. DETAILED DESCRIPTION

[0122] In the following text, a detailed description of the examples will be given with reference to the accompanying drawings. Various modifications may be made to the examples. In particular, one or more elements of one example may be combined and used in other examples to form new examples.

[0123] Figure 1 An exemplary neural network for performing a machine learning task is shown. More specifically, the neural network is used to perform a classification task. The neural network can be constructed according to the determined hyperparameter values. Therefore, the hyperparameter values ​​can define the structure of the neural network. The hyperparameter values ​​can include the number of layers and the number of neurons in each layer. Therefore, the neural network can be constructed according to the hyperparameters, so that the neural network includes an input 101, a first layer 103, a second layer 105, and an output layer 107. In addition, the output layer 107 includes four neurons. In addition, each of the layers 103 and 105 includes four neurons.

[0124] Therefore, the layers 103 and 105 of the neural network and the output layer 107 may each include the same number of neurons. In other words, each layer of the neural network may each include the same number of neurons.

[0125] The classification task of the simplified neural network has two categories, namely category 0 and category 1. Therefore, the classification task includes binary classification. For example, neurons 3.1 and 3.2 may each output "1", while neurons 3.3 and 3.4 may each output "0". In this case, the number of categories k is 2, and the number of neurons n in the outer layer 107 is 4, so that the outputs can be grouped into 2 groups of size 2. Therefore, the classification score of category 0 will be 2, and the classification score of category 1 will be 0. Therefore, determining the classification according to the maximum value of the classification scores will result in determining category 0 as the classification. In other examples, more categories can be used.

[0126] Each neuron 1.1 to 3.4 in the neural network receives two inputs from two different neurons. For example, neuron 1.4 in the first layer 103 receives inputs 0.5 and 0.6 of input 101.

[0127] Each neuron may include a corresponding probability for each of a plurality of logical operators. The probability of a neuron may be part of a probability distribution of the neuron, which may be learned when training the neural network. The logical operators may be real-valued (i.e., relaxed). Real-valued logical operators may be based on T-norms (relaxations of "and") and T-conorms (relaxations of "or"). Real-valued logical operators may be differentiable and / or continuous. Therefore, neither the drastic T-norm nor the minimal T-norm provides an appropriate basis for real-valued logical operators.

[0128] Real-valued logic operators can be viewed as an extension of conventional Boolean logic operators, in that real-valued logic operators are defined not only on inputs of 0 and 1, but also on inputs between 0 and 1.

[0129] An exemplary probability distribution for neurons 1.1 of layer 103 may include the following probabilities, as shown in Table 1:

[0130] AND OR NAND NOR XOR … TRUE FALSE 3% 1% 7% 2% 72% 9% 1%

[0131] Table 1

[0132] Table 2 shows the probabilistic interpretation of real-valued logical operators (probabilistic logical operators) and their corresponding Boolean interpretations:

[0133]

[0134] Table 2

[0135] In Table 2, the ID column identifies each row. The operator column shows the Boolean operator. A row of the real-valued column shows the real-valued operator corresponding to the Boolean operator in the row. The rows of columns "00", "01", "10", "11" show the output of the operator (Boolean value or real value) corresponding to the row given the header value of the column (e.g., "00") as input. Testing has shown that reducing the number of operators in Table 2 may result in reduced performance. In other words, using 16 logical operators, as opposed to less than 16 logical operators, can improve the efficiency of the method for training a neural network to perform a machine learning task.

[0136] The values ​​in Table 2 illustrate probabilistic logic operators. Other interpretations may also be used for real-valued logic operators. For example, the Hamacher product T-module and its dual, the Einstein and T-comodule, may be differentiable and provide a suitable basis for real-valued logic operators. Real-valued logic operators based on the Hamacher product T-module and the Einstein and T-comodule are shown in Table 3 below.

[0137]

[0138] Table 3

[0139] Some operators in Table 3 can be derived from other operators in Table 3. In Table 3, rows 2, 4 and 9, the corresponding Boolean operators do not have corresponding real-valued operators. For the meanings (rows 2 and 4 in Table 3), the R-meanings (or recombinants) corresponding to the T-norms can be used (see "Continuous R-implications" by B. Jayaram et al., published on July 20-24, 2009). It has been found that the probability operators of Table 2 perform better in tests than the Hamacher T-norms and Einstein and T-conorms of Table 3.

[0140] Other implementations of real-valued operators can be based on the Frank T-module, the Yager T-module, the Aczél-Alsina T-module, the Dombi T-module, and the Sugeno-Weber T-module and their corresponding T-comodules. More information about logical operators can be found in "Analyzing Differentiable Fuzzy Logic Operators", van Krieken et al., August 24, 2021.

[0141] Other T-norms and T-conorms that can be used to implement real-valued operators are shown in Tables 4 and 5 below:

[0142]

[0143] Table 4

[0144]

[0145] Table 5

[0146] During training Figure 1 Exemplary values ​​for the neurons are provided in the table below. Train the logical operator probability in the middle of the neural network:

[0147]

[0148] Probability of logical operators in the later stages of training neural networks (i.e. after convergence)

[0149]

[0150] Figure 1The neuron corresponding to each row of logical operator probabilities shown above is provided at the beginning of the row. For example, the row starting with "1.1" shows the value of neuron 1.1 in layer 103. Each column in the row of logical operator probabilities corresponds to a consecutive ID in Table 2. For example, column 1 of logical operator probabilities corresponds to ID 0 of Table 2, while column 2 of logical operator probabilities corresponds to ID 1. Therefore, in the middle of training, the highest probability for neuron 3.2 is 0.678, which corresponds to ID 10 of Table 2, i.e., real-valued operator 1-B.

[0151] The middle of training may refer to the number of epochs that the network has been trained. Thus, the middle of training may refer to about half the number of epochs. Similarly, the late stage of training may refer to an epoch within 10% of the final epoch. For example, if the neural network is trained for 200 epochs, the middle of training may be between epoch 90 and epoch 110. Similarly, the late stage of training may be between epoch 190 and epoch 200. Convergence may refer to the stage of training where additional training does not improve the neural network.

[0152] As can be seen from the exemplary values ​​above, for each neuron in the middle of training, there are multiple probabilities of logical operators between 0 and 1. However, after convergence, usually only one or two probabilities have values ​​different from 0, and at least one value is close to 1.

[0153] Figure 2 A neural network is shown for performing a regression task. In this case, instead of "class 0" or "class 1", the output of the neural network is the value of the output layer 107. More specifically, the output may be an array of Boolean values ​​(i.e., a vector of values, where each value may be either 0 or 1). Alternatively, there may be a scalar output.

[0154] More specifically, to generate (ie, predict) a k-dimensional output, there may be n neurons in the output layer 107. The outputs may be grouped into k groups (eg, size n / k). For each dimension i of the output (prediction), there may be a scalar parameter ∝ i , so that ∝ i n / k is valid and provides a definite (expected) range for the output (prediction).

[0155] For example, when the regression task is to predict rainfall, there may be 1 dimension, and when the regression task is to predict rainfall and wind speed, there may be 2 dimensions. The determined range of rainfall can be 0 to 200 mm. In another example, when the regression task is image generation, k can be the number of pixels; therefore, to generate a 784 pixel image, k can be 784.

[0156] The final output may be determined by counting the 1 values ​​of the output neurons in the output layer 107 .

[0157] To generate outputs with both positive and negative values, a bias β i To shift the determined range (i.e., output space). Therefore, the final output can be determined by counting the output neurons and applying an affine transformation as follows:

[0158]

[0159] An affine transformation may be used to transform (or shift) the determined range from 0 to a more appropriate application-specified range.

[0160] In some cases, all dimensions of the output have the same range, so α = α for all i i and β = β i .

[0161] In some cases, it may be desirable to determine a range that covers all real numbers, which can be achieved using a logit transformation as follows:

[0162]

[0163] in,

[0164] Using the output, the mean square error (MSE) loss can be formulated as:

[0165]

[0166] In other respects, Figure 2 The neural network corresponds to Figure 1 of neural networks.

[0167] Figure 3 A method for training a neural network to perform a machine learning task is shown. The neural network may correspond to the above Figure 1 and Figure 2 of neural networks.

[0168] The neural network may be referred to as a deep differentiable logic gate network that performs all calculations on Boolean values ​​as binary operations after training, rather than floating point calculations typically performed in conventional neural networks. The operators of each neuron in the neural network may be implemented exclusively using logic gates. This may result in a very sparse network and improve efficiency when performing machine learning tasks with the trained neural network. Efficiency may be further improved by expanding the data (e.g., test data) for the machine learning task on the neurons of the first layer 103.

[0169] In step S201, input data for a neural network is received. The input data may be received as a binary value input 101, such that each neuron in layers 103 to 105 receives two inputs. The input data may include training data, validation data, and test data. The training data may be used to learn the probability distribution of each neuron. The validation data may be used to determine whether the neural network is sufficiently accurate, i.e., to determine whether training is complete. The test data may be used during inference (after training is complete), for example, to evaluate the neural network relative to other or conventional neural networks.

[0170] In step S203, the values ​​of multiple hyperparameters of the neural network are determined. The hyperparameters may include the number of layers (e.g., about 2 to about 32), the number of neurons in each layer (e.g., about 12 to about 1,024,000), and the learning rate.

[0171] For example, each layer may have the same number of neurons. Additionally or alternatively, there may be about 4 to about 8 layers. This may result in the advantage of not needing to fine-tune the architecture / structure of the neural network. Thus, this may simplify and speed up the determination of hyperparameters.

[0172] The learning rate may have a constant value of approximately 0.01.

[0173] In step S205, a neural network may be constructed according to the hyperparameter values. This may include generating the number of layers (e.g., 4) and the number of neurons in each layer (e.g., 8000) according to the hyperparameter values. Construction may include pseudo-randomly initializing the connections between neurons, i.e., the weights of the network. Other means of initializing the connections (i.e., weights) are also possible. For example, a trained neural network with weights determined according to conventional methods may be used as a basis.

[0174] Each neuron may include a probability distribution for multiple logical operators. Each of the logical operators may have the following characteristics:

[0175] f:{0,1}x{0,1}→{0,1}

[0176] Instead of hard binary values ​​p∈{0,1}, the probability distribution can be relaxed to p∈[0,1] 16 . This can be a step to make the neural network differentiable.

[0177] In a neural network, a single neuron can be defined as follows. The two inputs of a neuron can be defined as a, b∈[0,1]. Therefore, p is a probability simplex Δ 15 and is a probability distribution over logical operators. p can be obtained by parameterized, where p = softmax(q). In addition, Op i(·,·) may be a real-valued logical operator with ID i according to Table 2 above. The output o of the neuron may then be defined as

[0178]

[0179] The output o can be ∈[0, 1].

[0180] By representing the choice of which logical operator (i.e., logic gate) is present in each neuron by a probability distribution (e.g., a categorical probability distribution), training can be performed (e.g., using a gradient descent-based algorithm) because neurons in a neural network can be distinguished from each other even with binary inputs, i.e., the values ​​in the network will no longer be restricted to ∈{0, 1}.

[0181] Advantageously, the storage requirements for storing a neural network can be significantly less than the storage requirements for a neural network that performs floating point operations instead of using logical operators. For example, the plurality of logical operators may consist of 16 logical operators. Thus, after training the neural network, only 4 bits are required to represent the logical operator for a given neuron. In other words, only 4 bits are required to store information that specifies the operation performed by a given neuron. This may be much less than the storage required in a neural network in which neurons perform more complex operations.

[0182] In a conventional sparse neural network, the connections between neurons (weights) of the sparse neural network can be trained.

[0183] In step S207, the neural network may be trained according to the hyperparameter values. Compared to conventional sparse neural networks, training the neural network may include learning which logical operator (i.e., binary function) is implemented at each neuron, while the connections between neurons remain fixed after initialization. Thus, the learning goal may be to determine which logical operator should appear on each neuron. Thus, the network may be (continuously) parameterized by learning the probability distribution of the logical operator at each neuron.

[0184] The neural network can be relaxed. In other words, instead of fixed logical operators, probability distributions of logical operators can be used, and the neural network can operate on the probabilities during training. Relaxing the logical operators can be another step to make the neural network differentiable. Learning the probability distribution of each neuron can be achieved via a (relaxed) softmax parameterization.

[0185] Learning the probability distribution can be accomplished by parameterizing each neuron with 16 floating point values ​​corresponding to the 16 logical operators. Softmax can be used to map the 16 floating point values ​​to a probability simplex (i.e., a categorical probability distribution such that all entries add up to 1 and there are only non-negative values). Referring to the discussion above of Equation 4, parameterizing the neurons during initialization of the neural network can include selecting (drawing) the elements of q independently of the standard normal distribution.

[0186] Training may include evaluating all 16 logical operators for each neuron and computing their weighted average using the classification probability distribution. Thus, during training, the output of all neurons may be ∈ [0, 1].

[0187] More specifically, for a classification task with k classes and n neurons in the output layer, the output can be grouped into k groups of size n / k. In this way, the classification score for each class can be determined by counting the number of 1s in each group. Therefore, in the context of a classification task, the output of the neural network can be determined by taking the argmax of the classification scores.

[0188] To determine whether the neural network is accurate enough, the probabilities of the outputs in each group can be summed instead of counting the number of 1s. Therefore, a measure of accuracy can be determined by calculating the classification loss. For example, the softmax cross entropy classification loss can be calculated as follows:

[0189]

[0190] For the output neuron (o i ) i∈{1...n} , for the obtained (true) category (y j ) j∈{1...k} One-hot encoding is performed, and the softmax temperature τ is one-hot encoded. The Adam optimization algorithm can be used for training.

[0191] After training is complete, the two inputs to the neuron can be defined as a, b∈{0,1}. Thus, in contrast to the neuron during training (see Equation 4), where the input to the neuron can be a floating point value ≥0 and ≤1, after training, the input to the neuron can be a Boolean value, i.e., 0 or 1. Similarly, the output o of the neuron can be ∈{0,1}. Thus, the output o of the neuron after training can be defined as follows

[0192] o=Op r (a, b) (Equation 6)

[0193] Where, in Equation 6, r = argmax i p i . i refers to the ID in Table 2.

[0194] In step S209, a logical operator may be determined for each neuron. The logical operator may be determined after training is completed, i.e., during inference. The determined logical operator may be the most likely logical operator, for example, the logical operator of the probability distribution with the highest probability. In other words, the probability distribution may be discretized by taking their mode. Therefore, the machine learning task may be performed by calculating Boolean values ​​instead of floating point values, thereby making classification efficient compared to neural networks that rely on floating point operations.

[0195] Before using the trained neural network to perform a machine learning task, the neural network can be compiled into at least one binary executable file. The binary executable file can be processor-dependent. For example, two binary executable files can be compiled, one for the CPU (e.g., from C code) and one for the GPU (e.g., from CUDA).

[0196] Additionally, logical expressions and / or sub-expressions may be simplified. For example, instead of a Boolean data type, a data type corresponding to the hardware implementation of the processor on which the machine learning task is to be performed may be used.

[0197] For example, for a 64-bit CPU, the data type implemented in hardware may be integer64. Additionally, an aggregate size of 64 may be used, meaning that 64 samples (e.g., images) are processed by the neural network in a given iteration (i.e., epoch). On a GPU, the output neurons may be aggregated directly using logic gates that make up the corresponding adders, since any writes to the GPU memory may result in a bottleneck (i.e., reduced performance). Typically, the bottleneck (point in the system that may result in a reduction in speed) may be the data loader and / or the transfer speed.

[0198] Therefore, bit-by-bit operations can be performed on larger batches, which can have a significant impact on the speed at which machine learning tasks can be performed.

[0199] The output layer 107 may generate multiple outputs per category. The outputs may be aggregated via bit counts (i.e., by counting 1s), which generates a score for each category. Thus, when the machine learning task is a classification task, the classification task may be accomplished by providing the category with the highest score as the output of the neural network.

[0200] When performing a machine learning task given a binary vector as input, pairs of Boolean values ​​may be selected from the binary vector, logical operators (i.e., binary logic gates) of one of the layers (e.g., layer 103) may be applied to the Boolean values, and their outputs may then be used in subsequent layers (e.g., layer 105 or layer 107) in the neural network.

[0201] After training, the computational cost of performing machine learning tasks can be reduced by at least an order of magnitude compared to conventional binary and sparse neural networks, and possibly even further compared to other types of conventional neural networks.

[0202] An exemplary machine learning task is the MONK problem, as discussed in "The monk's problems: A performance comparison of different learning algorithms" by Thrun et al., 1991. MONK's problems - MONK-1, MONK-2, and MONK-3, are three machine learning tasks that have been used to benchmark machine learning algorithms. They consist of three binary classification tasks on a data set with six attributes, each with 2-4 possible values. Therefore, the data points (samples) can be encoded as binary vectors of size 17.

[0203] Tests show that the neural network discussed above performs more accurate classification than logistic regression on all three MONK datasets. In addition, for MONK-3, the neural network discussed above (i.e., Figure 1 and Figure 2 ) is more accurate than a much larger convolutional neural network. In addition, the neural network discussed above is more than three times faster than logistic regression and more than seven times faster than a larger convolutional neural network. In addition, the neural network discussed above requires significantly less storage space than either logistic regression or convolutional neural networks.

[0204] As another exemplary machine learning task, consider the adult census ("Uci machine learning repository: Adult data set" by Kohavi et al., 1996) and breast cancer ("Uci machine learning repository breast cancer dataset" by Zwitter et al., 1988) datasets. With respect to the adult dataset, the machine learning task is to predict whether a given adult's annual income exceeds $50,000 based on attributes such as education and weekly work hours. With respect to breast cancer, the machine learning task includes binary classification and involves determining whether a cancer diagnosis is benign or malignant based on features of the cell nucleus including perimeter, area, and smoothness. For these tasks, the (classification) accuracy achieved by the neural networks discussed above is comparable to that of conventional (convolutional) neural networks and logistic regression. In addition, the classification speed is more than 10 times faster than logistic regression and more than 40 times faster than conventional neural networks. In addition, the neural networks discussed above require approximately 20% less storage space than logistic regression and approximately 75% less storage space than conventional neural networks.

[0205] In addition, very high frame rates can be achieved in image classification. For example, for the neural network discussed above, frame rates of more than one million images per second can be achieved on images of the modified National Institute of Standards and Technology (MNIST) data set (http: / / yann.lecun.com / exdb / MNIST / ) and the Canadian Institute for Advanced Research (CIFAR-10) data set ("Learning Multiple Layers of Features from Tiny Images" published by Alex Krizhevsky on April 8, 2009). In other words, a single CPU core can be used to achieve a classification rate of more than one million images per second. This may exceed the efficiency of any conventional method.

[0206] More specifically, the neural network discussed above can have image classification accuracy on the MNIST data set comparable to the fastest conventional binary neural network, while requiring less than 10% of the number of binary operations. On a standard GPU (e.g., NVIDIA A6000), the neural network discussed above can execute 12 times faster than a conventional binary neural network on dedicated FPGA hardware, even though the neural network discussed above only requires 7% GPU utilization. Compared to another conventional binary neural network, the neural network discussed above can be approximately three orders of magnitude faster. Compared to an evolutionarily learned sparse function network, the neural network discussed above is more accurate.

[0207] For image classification using the CIFAR-10 dataset, the neural networks discussed above can be comparable in accuracy to conventional convolutional neural networks, while requiring less than 0.1% of the memory in some cases and less than 1% of the memory in other cases. However, a dedicated fully connected network can be slightly more accurate (less than 4%) at the expense of requiring 64% more memory.

[0208] When performing image classification using the CIFAR-10 dataset, a conventional fully connected neural network that relies on floating point operations may require 2,000,000 floating point operations to perform a machine learning task, while the neural network discussed above, before pruning or optimization, requires 5,000,000 bitwise logic operations. On an integrated circuit with floating point arithmetic hardware acceleration (e.g., modern GPUs and many CPUs), 2,000,000 floating point operations are about 100 times slower than 5,000,000 bitwise logic operations. Without floating point arithmetic acceleration, the speed difference would be an order of magnitude larger, i.e., the difference would be three orders of magnitude.

[0209] Even a regular sparse neural network, although faster than a regular fully connected neural network, is still at least an order of magnitude slower than the neural network discussed above. A sparse neural network requires at least twice the storage space of the neural network discussed above.

[0210] The above discussion (combined with Figure 1 and Figure 2 A possible exemplary architecture of a neural network of ) is shown in Table 6 below:

[0211]

[0212] Table 6

[0213] Table 7 shows the configuration of the fully connected ReLU network, which is used as the basis for comparison with the neural network configuration of Table 6.

[0214]

[0215] Table 7

[0216] In addition, an average of approximately 250 binary logic gates may be calculated on each core of the CPU in each clock cycle (i.e., per Hertz) of the CPU on a typical general-purpose desktop or laptop computer. This is possible because a typical CPU executes many instructions per clock cycle even on a single core. This may be significantly faster than is possible when executing a neural network that relies on floating-point operations. Additionally, the CPU may enable data for a machine learning task to be spread across the neurons of the first layer 103 by grouping bits from multiple samples of data (e.g., images) into a single integer (e.g., an integer with a data type of integer 64). Grouping bits from multiple samples into a single integer may be referred to as single instruction multiple data (SIMD). Additional efficiency gains may be possible using Advanced Vector Extensions (AVX).

[0217] The computational cost of a portion of a machine learning task performed by a layer with n neurons (e.g., layer 103, layer 105, or layer 107) may be O(n) including a small constant cost, since only Boolean logic gates are required (i.e., operations are performed only via logical operators and can therefore be performed very efficiently). By comparison, a fully connected layer with m input neurons has a significantly higher constant cost computational cost of O(n·m), particularly since fully connected layers typically require floating point arithmetic. In general, using the method described in reference Figure 1 and Figure 2 The described method trains a neural network to perform machine learning tasks that can lead to inference speeds that are two orders of magnitude faster than fully connected ReLU neural networks (neural networks using the ReLU activation function). Figure 1 and Figure 2The neural network trained by this method can be more than 13 times faster than the conventional binary neural network and 2 to 3 orders of magnitude faster than the theoretical speed of conventional sparse neural networks.

[0218] Figure 4 shows the distribution of logic gates on a neural network once it has been trained to perform a machine learning task. In this case, the machine learning task consists of image classification. The neural network has four layers, with 12,000 neurons in each layer. The values ​​on the X-axis correspond to the IDs in Table 2 for layers 1 and 2 and the values ​​on the X-axis for layers 3 and 4. The values ​​on the Y-axis provide a count of the number of neurons in which the logical operators on the X-axis are present.

[0219] It can be seen from Figure 4 that the constant logical operators "0" and "1" (corresponding to IDs 0 and 15 in Table 2) are used very rarely and do not appear at all in layer 4. In the first layer, "and", "nand", "or", and "nor" have relatively strong probabilities.

[0220] In the second and third layers, more "A", "B", and They can be viewed as residual direct connections, since one of the two inputs is ignored and the other is fed forward (possibly in a modified form) to the next layer. This can enable a neural network to model lower-order dependencies more efficiently by representing them with fewer than a predetermined number of layers.

[0221] In layer 4, the most frequent operations are "xor" and "xnor", which create conditional dependencies on the activations of the previous layer. As shown in the figure, these meanings are rarely used. However, testing has shown that using only an appropriate subset of logical operators (rather than all 16 operators with the probabilistic interpretation of Table 2) can lead to reduced accuracy.

Claims

1. A computer-implemented method for training a neural network to perform a machine learning task such as image classification, comprising: Receiving input data of the neural network (S201); Determining values ​​of a plurality of hyperparameters of the neural network (S203); constructing the neural network according to the hyperparameter value, wherein the neural network includes a plurality of neurons (1.1-3.4) (S205), wherein each neuron (1.1-3.4) comprises a probability distribution of a plurality of logical operators, such that said neuron (1.3-3.4) comprises a corresponding probability of each of said logical operators, By learning the probability distribution of each neuron (1.3-3.4), the neural network is trained according to the hyperparameter value and the input data (S207); and By selecting a value in the probability distribution, a logical operator from the plurality of logical operators for each neuron (1.3-3.4) is determined (S209).

2. The method according to any one of the preceding claims, in, The input data includes input and corresponding expected output, The input data includes one or more of the following: training data, verification data and test data.

3. The method according to claim 1 or 2, in, determining the hyperparameter values ​​so as to minimize the validation error of the neural network under one or more specified computing resource constraints, The specified computing resource constraints may include processor and / or memory constraints.

4. The method according to any one of the preceding claims, in, The hyperparameters include one or more of the following: neurons per layer, number of layers, number of epochs, batch size, and learning rate.

5. A method according to any one of the preceding claims, wherein: The neural network comprises a plurality of layers including an output layer (107).

6. The method according to claim 5, in, The output layer (107) comprises n neurons, wherein the machine learning task is a classification task with k categories, The method further includes using the trained neural network to perform the classification task, including: Outputting a classification score for each of the categories through the trained neural network; grouping the output into k groups of size n / k, where the number of 1s in each group corresponds to the classification score of the class corresponding to the group; Determining a classification, wherein determining the classification includes: determining a maximum value of the classification scores.

7. A method according to any one of the preceding claims, wherein: After training the neural network and before performing the machine learning task, the method further comprises: converting the trained neural network into binary executable on a central processing unit or a graphics processing unit, Wherein, the executable binary can be called via a program capable of processing a shared object binary, wherein the program can be in Python.

8. The method according to any one of the preceding claims, in, The output of each neuron is a value in the range 0 to 1, and / or Each neuron receives between 0 and 3 inputs.

9. A method according to any one of the preceding claims, wherein: Constructing the neural network further includes pseudo-randomly initializing connections between the neurons; During the training, the connections between neurons can remain fixed.

10. A method according to any one of the preceding claims, wherein: The machine learning task is a classification task including one or more of the following: Binary classification, pattern recognition, image classification, object identification or recognition, character recognition, gesture or facial recognition, speech detection or voice recognition, text classification.

11. A method according to any one of the preceding claims, wherein: The machine learning task is a regression task, wherein the regression task includes one or more of the following: Generate images, generate text, generate videos, generate speeches, 3D reconstruction, compression, encoding.

12. The method according to any one of the preceding claims, in, The plurality of logical operators includes at least 2 operators or exactly 16 operators; Wherein, the plurality of logical operators can be real-valued operators; The real-valued operator can conform to one of the following interpretations: probability, Hamacher t-norm, relativistic Einstein and t-conorm, Lukasiewicz t-norm, and t-conorm.

13. The method according to any one of the preceding claims, in, The input data includes test data having a plurality of samples; During inference, the machine learning task is performed by accessing the collection of test data by a first layer (103) of the neural network, the accessing comprising assigning elements of each sample of the test data to consecutive bits of an integer, Wherein, during inference, the two inputs to each neuron have digital data types corresponding to the data types implemented by the hardware of the processor of the computer on which the machine learning task is performed.

14. A computer program comprising instructions which, when executed by a computer, cause the computer to perform a method according to any one of the preceding claims.

15. A computer system for training a neural network to perform a machine learning task such as image classification, comprising: At least one processor configured to: Receiving input data of the neural network; determining values ​​of a plurality of hyperparameters of the neural network; constructing the neural network according to the hyperparameter value, wherein the neural network includes a plurality of neurons (1.3-3.4), wherein each neuron (1.3-3.4) comprises a probability distribution of a plurality of logical operators, such that said neuron (1.3-3.4) comprises a corresponding probability of each of said logical operators, Training the neural network according to the hyperparameter values ​​and the input data by learning the probability distribution of each neuron (1.3-3.4); and By selecting a value from said probability distribution, a logical operator from said plurality of logical operators is determined for each neuron (1.3-3.4).