An efficient local learning system and method supporting arbitrary network topology
By providing an efficient local learning system that supports arbitrary network topologies, the application challenges of local learning methods in complex networks have been solved, resulting in improved training speed and simplified interfaces, thus promoting the development of local learning.
Patent Information
- Application Number
- CN202311846519.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2043-12-29
AI Technical Summary
Existing local learning methods are difficult to apply to complex/deep deep learning networks, and existing frameworks do not support local learning research well. This forces researchers to spend a lot of time and computing resources on model training and inference, hindering the development of this field.
This paper presents an efficient local learning system that supports arbitrary network topologies. It includes a module layer and an operator layer, and encapsulates various operators, datasets, gradient derivative classes and optimizer classes. By combining just-in-time compilation and parallel technology, it simplifies the user interface and improves training and inference speed.
It can support users in creating complex network topologies, significantly improve training speed, reduce resource consumption, and provide a simple and easy-to-use interface, reducing the development difficulty for researchers and promoting the application of local learning.
Smart Images

Figure CN118378684B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of artificial intelligence, and particularly relates to a high-efficiency local learning method supporting an arbitrary network topology. BACKGROUND
[0002] The back propagation algorithm (BP) is the basis for the success of deep learning. Deep learning based on the BP algorithm can be widely applied to various aspects of life, such as computer vision, natural language processing, speech recognition, medical field, autonomous driving, etc., due to its powerful feature extraction and learning ability. However, it needs continuous backward update and non-local calculation, which makes large-scale parallel tasks challenging, and the learning rule is different from the learning way of the brain, which is not biologically reasonable. Therefore, algorithms represented by PC [1, 2, 5] and EP [3, 6] with biological rationality have been proposed, which can operate with more reasonable biological characteristics and effectively calculate the parameter gradient similar to the BP method. However, these algorithms exist independently, and there is no unified theory to connect them together. Therefore, Millidge, B. et al. [4] unified them with energy-based models (EBM). Energy-based models are a class of neural network models with biological rationality and robustness, and predictive coding (PC) and equilibrium propagation (EP) are two representative learning methods. They have natural advantages in explaining the information processing mechanism of biological nervous systems and have broad research and application prospects in the fields of neuroscience and machine learning. However, due to its strong theoretical nature, it has not been given specific experimental verification, making it difficult to map to specific algorithm implementation, unable to consider its computational efficiency, resource consumption, etc., and currently there is no framework that can support this type of research in a friendly manner. Researchers need to spend a lot of time on network construction, state and parameter update, etc., which greatly hinders the development of local learning theory.
[0003] The local learning method represented by PC and EP makes "intelligence" possible due to its biological rationality. However, this research is still in the theoretical research stage, and there are still many problems to be solved, such as:
[0004] 1) Currently, local learning can only be applied to simple sequential network structures [1, 3], and it is difficult to apply to complex / deep deep learning networks, which makes it difficult to apply this research to people's lives at the moment;
[0005] 2) Existing local learning projects based on PyTorch implementation need to spend a lot of time and computing resources in local learning model training and inference;
[0006] 3) Currently there is no framework to effectively support local learning research, researchers need to manually implement model energy calculation process, state update, gradient calculation and other processes based on existing deep learning frameworks (such as PyTorch, etc.), which is quite difficult to implement, especially for complex models, which greatly hinders the development of local learning theory and related application landing.
[0007] The information of the literature cited in the application is as follows:
[0008] [1] James C.R. Whittington, Rafal Bogacz; An Approximation of the Error Backpropagation Algorithm in a Predictive Coding Network with Local Hebbian Synaptic Plasticity. Neural Comput 2017; 29(5): 1229-1262;
[0009] [2] Millidge, B., Tschantz, A., & Buckley, C.L. (2022). Predictive coding approximates backprop along arbitrary computation graphs. Neural Computation, 34(6), 1329-1368;
[0010] [3] Scellier, B., & Bengio, Y. (2017). Equilibrium propagation: Bridging the gap between energy-based models and backpropagation. Frontiers in computational neuroscience, 11, 24;
[0011] [4] Millidge, B., Song, Y., Salvatori, T., Lukasiewicz, T., and et al. (2022). Backpropagation at the infinitesimal inference limit of energy-based models: unifying predictive coding, equilibrium propagation, and contrastive hebbian learning. arXiv preprint arXiv:2206.02629.
[0012] [5] Rosenbaum R (2022) On the relationship between predictive coding and backpropagation. PLoS ONE 17(3): e0266102.
[0013] [6] Laborieux A, Maxence E and et al. "Scaling equilibrium propagation to deep convnets by drastically reducing its gradient estimator bias." Frontiers in neuroscience 15 (2021): 633674. SUMMARY
[0014] The present invention aims to provide an efficient local learning system and method, which has the following goals:
[0015] a) Support any network topology, allowing users to create complex network models as needed;
[0016] b) Reduce the training and inference speed of local learning networks using just-in-time compilation and parallel technology;
[0017] c) Provide a simple, easy-to-use, and flexible user interface to reduce the development difficulty of deep learning and local learning researchers, allowing them to quickly get started.
[0018] The present invention provides an efficient local learning system that supports any network topology, which is applied to various local learning tasks and implemented by electronic devices with computing capabilities. The system includes a module layer and an operator layer, wherein:
[0019] The module layer encapsulated module includes: rlayer module, datasets module, grads module, metrics module, and optimizer module; wherein,
[0020] The rlayer module includes a plurality of operators for creating a network, at least including: convolution operator, pooling operator, normalization operator;
[0021] The datasets module includes a plurality of public dataset download, loading and preprocessing classes;
[0022] The grads module includes a plurality of local learning derivative classes;
[0023] The metrics module includes a plurality of deep learning measurement indicators;
[0024] The optimizer module includes a plurality of optimizers;
[0025] The operator layer encapsulated operator class, gradient solving class, optimizer class, dataset class and measurement indicator function correspond to the module layer encapsulated module, and are used for providing the interface of the module layer encapsulated module, and include:
[0026] Corresponding to the rlayer module, at least encapsulated: RConv1d operator, RConv2d operator, Rconv3d operator, RSequential operator, RWeightNorm operator, RMaxPoll operator, RMinPoll operator, RAvgPoll operator;
[0027] Corresponding to the datasets module, at least encapsulated: MNIST, CIFAR10, and CIFAR100 dataset download and preprocessing class;
[0028] Corresponding to the grads module, at least encapsulated: PC local learning gradient derivative class, BiPC local learning gradient derivative class, and EP local learning gradient derivative class; in addition, the gradient derivative base class LocalBase is also included, and users can rewrite the corresponding method according to own demand to realize the local learning derivative class; corresponding to the metrics module, at least encapsulated: model accuracy calculation function, loss calculation function;
[0029] Corresponding to the optimizer module, at least encapsulated: Adam optimizer, SGD optimizer;
[0030] The operator of the module layer package, the dataset download and preprocessing class, the optimizer class, the gradient derivation class and the index calculation function all have input and output interfaces, and a user can create and instantiate a network on demand through the rlayer module, download and preprocess a corresponding dataset through the datasets module, select a corresponding optimizer through the optimizer module, select a local learning gradient derivation class through the grads module, select a loss and accuracy calculation function through the metrics module, complete the initialization of the network and the corresponding hyperparameters, and realize network training and testing.
[0031] Further, the local learning method at least includes: StrictPC, FixedPredPC, BiPC, EP two phase, and EP three phase.
[0032] Further, the processor of the electronic device is: a CPU, a GPU, or a BPU.
[0033] Further, the network structure is defined as: taking an operator calculation flow as an edge and taking the output of the operator as a node; the operator includes an a_mat attribute and an operation attribute, wherein the a_mat attribute is used for storing the node ID connected with the edge, and the operation attribute is used for storing the operation involved by the previous node adjacent to the edge; and the network structure form at least includes: a unidirectional network, a bidirectional network and a skip connection network.
[0034] The application also provides a high-efficiency local learning method supporting an arbitrary network topology, which is realized by the high-efficiency local learning system supporting the arbitrary network topology and includes the following steps:
[0035] Step 1: constructing a network required by a user by calling multiple operators through the rlayer module;
[0036] Step 2: instantiating the created network and setting various hyperparameters;
[0037] Step 21: instantiating the created network to obtain network parameters;
[0038] Step 22: calling the dataset download, loading and preprocessing class under the datasets module, setting a BatchSize, and performing data normalization on the loaded training dataset and test dataset;
[0039] Step 23: calling the optimizer module, selecting an optimizer, setting a learning rate and other parameters to complete the initialization of the selected optimizer;
[0040] Step 24: calling the grads module and selecting a local learning gradient derivation class.
[0041] Step 3, based on the instantiated network and hyperparameters, network energy solving, state updating, gradient calculation are performed;
[0042] Step 31, traverse each instantiated operator in the network to obtain all attributes of the operator, judge whether the attribute is inherited from the instantiated object of the parent class Module, if yes, obtain the forward and reverse calculation process, a_mat, operation attribute of the object and the network parameters corresponding to the operator, store them in a list adj_mat, user energy function calculation, state update, gradient calculation operation
[0043] Step 32, calculate the network energy according to the energy function to obtain the final network node state;
[0044] Step 33, calculate the network energy according to the obtained final network node state, and perform derivative operation on the network parameters to obtain the network parameter gradient.
[0045] Step 4, update the network parameters based on the network parameter gradient to perform the next iteration training;
[0046] Step 5, constantly iterate steps 3-4 until the network training reaches the convergence condition set by the user.
[0047] Further, step 32 is specifically:
[0048] Step 321, traverse adj_mat to perform model forward calculation and initialize network node state;
[0049] Step 322, calculate the network energy according to the energy function and perform derivative operation on the network node state to obtain the network node state change;
[0050] Step 323, update the network node state according to the initialized network node state and network node state change;
[0051] Step 324, repeat steps 322-323 until the network node state reaches a steady state to obtain the final network node state.
[0052] Further, step 33 is specifically: when the user selects the EP two phase derivative method, the following steps are performed to obtain the network parameter gradient:
[0053] Step 3311, perform steps 322-324 to obtain the first stage network node state, and record the first stage network node state as steady state V1, calculate the network energy based on the steady state V1 and perform derivative operation on the network parameters to obtain the network parameter gradient g1;
[0054] Step 3312, based on the steady state V1 obtained in steps 322-324, a second stage network node state is obtained, denoted as steady state V2, based on the steady state V2, the network energy is calculated and the network parameters are derived, and the network parameter gradient g2 is obtained;
[0055] Step 3313, the final network parameter gradient is calculated according to g1 and g2.
[0056] Further, step 33 is specifically: when the user selects the local learning derivation method as the EP three phase method, the following steps are executed to obtain the network parameter gradient:
[0057] Step 3321, the first stage network node state is obtained by executing steps 322-324, denoted as steady state V1, based on the steady state V1, the network energy is calculated and the network parameters are derived, and the network parameter gradient g1 is obtained;
[0058] Step 3322, an external energy function is introduced, based on the steady state V1, steps 322-324 are executed to obtain the second stage network node state, denoted as steady state V2, based on the steady state V2, the network energy is calculated and the network parameters are derived, and the network parameter gradient g2 is obtained;
[0059] Step 3323, an external energy function is introduced, based on the steady state V1, steps 322-324 are executed to obtain the third stage network node state (steady state V3), based on the steady state V3, the network energy is calculated again and the network parameters are derived, and the network parameter gradient g3 is obtained;
[0060] Step 3324, the final network parameter gradient is calculated according to g3 and g2.
[0061] Further, step 33 is specifically: when the user selects the local learning derivation method as StrictPC or FixedPredPC, the following steps are executed to obtain the network parameter gradient: the network node state is obtained by executing steps 322-324, denoted as steady state V1, based on the steady state V1, the network energy is calculated and the network parameters are derived, and the network parameter gradient is obtained as the final network parameter gradient.
[0062] Further, step 33 is specifically: when the user selects the local learning derivation method as BiPC, the following steps are executed to obtain the network parameter gradient: when calculating the network energy, the reverse node state in the network needs to be considered, steps 322-324 are executed to obtain the first stage network stage state, denoted as steady state V1, based on the steady state V1, the network energy is calculated and the network parameters are derived, and the network parameter gradient obtained is as the final network parameter gradient.
[0063] Further, instant compilation and parallel technology are adopted to improve network training and inference speed.
[0064] The application further provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the efficient local learning method supporting an arbitrary network topology when executing the computer program.
[0065] The application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program implements the steps of the efficient local learning method supporting an arbitrary network topology when executed by a processor.
[0066] The application constructs an efficient local learning system and method supporting an arbitrary network topology based on JAX, which can not only support users to create an arbitrary complex local learning network, but also greatly improve network training speed and effectively reduce resource consumption. In addition, the system provides a simple and easy-to-use local learning interface that can be flexibly extended. Users can implement corresponding tasks based on existing local learning methods [1-6], or inherit the local learning base class, rewrite the energy function, state calculation and update, and gradient calculation and update interface to implement more complex local learning tasks. BRIEF DESCRIPTION OF DRAWINGS
[0067] Figure 1 FIG. 1 is a schematic diagram of the efficient local learning system supporting an arbitrary network topology of the application;
[0068] Figure 2 FIG. 2 is a network construction schematic diagram of the application;
[0069] Figure 3 FIG. 3 is a local learning flowchart of the application;
[0070] Figure 4 FIG. 4 is an instant compilation flowchart of the application;
[0071] Figure 5 FIG. 5 is a structural diagram of an electronic device according to an embodiment of the application. DETAILED DESCRIPTION
[0072] To make the objectives, technical solutions and advantages of the embodiments of the application clearer, the technical solutions in the embodiments of the application will be described below in connection with the drawings of the embodiments of the application. Obviously, the described embodiments are only some of the embodiments of the application, but not all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the application.
[0073] The present application proposes an efficient local learning system and method supporting arbitrary network topology, which includes but is not limited to: optimizing existing deep learning operators to enable the creation of arbitrary topology network structure in the form of a graph; optimizing existing local learning methods, redefining and implementing network energy calculation, network node state calculation, gradient calculation and update function to enable various network topologies; applying just-in-time compilation technology to improve local learning model training and inference speed, etc.
[0074] The present application will be described in detail below with reference to the accompanying drawings.
[0075] Figure 1 The efficient local learning system supporting arbitrary network topology of the present application is shown 。 The operators developed by the system are downward compatible with various hardware and provide users with many local learning algorithm interfaces. As shown, the system includes a module layer and an operator layer. The system of the present application is also associated with a user layer and a hardware layer. Each layer will be described in detail below. Figure 1
[0076] 1. Hardware layer
[0077] The system can support various hardware, such as CPU, GPU, BCU, etc. For large-scale deep learning network training, it is recommended that users choose devices with GPU environment.
[0078] 2. Operator layer
[0079] (1) In terms of data sets, the system provides public data sets such as MNIST, CIFAR10, CIFAR100 for users to choose from;
[0080] (2) In terms of local learning algorithms, PC, BiPC, and EP local learning gradient derivation classes are provided, where the PC class includes the one-way prediction encoding StrictPC[1,5], FixedPredPC[5] method, the BiPC class includes the two-way prediction encoding BIPC method, and the EP includes the TWO_PHASE[3], THREE_PHASE[6] method; users can choose the corresponding local learning method according to the specific application scenario and application field, in addition, the layer also provides the gradient derivation base class LocalBase, and users can rewrite the corresponding method according to their own needs to realize their own local learning derivation class;
[0081] (3) In terms of deep learning measurement indicators, commonly used measurement indicators such as model accuracy and loss function are provided;
[0082] (4) In terms of optimizers, the system provides commonly used optimizers such as Adam and SGD;
[0083] (5) In terms of operators, the system provides convolution, pooling, normalization, etc. In our system, we define the operator calculation process as an edge and the output of the operator as a node. In order to make the deep learning operator better adapt to the local learning task and facilitate users to create different topologies of deep learning network (such as Figure 2 the various network topology diagrams in FIG. 1), we encapsulate the traditional deep learning operator, add a_mat and operation attributes to the operator, where the a_mat attribute is used to store the node ID connected to the edge, and the operation attribute is used to store the previous node ID adjacent to the edge and the operation involved, such as Figure 2 the fourth network topology diagram in FIG. 1, the nodes v1, v2 are concatenated and used as the input nodes of the edge f3, in addition, the system also adds a reverse calculation function to each operator, where the reverse calculation and the forward calculation share the model weight of the operator.
[0084] 3. Module layer
[0085] We divide the operator layer into types and place the classes involved in the corresponding operators under the corresponding modules.
[0086] (1) The datasets module contains some public dataset download, loading and preprocessing classes;
[0087] (2) The grads module contains PC, BiPC, EP and other local learning derivative classes.
[0088] (3) Under the metrics module, some loss, accuracy and other index calculation functions are integrated;
[0089] (4) Add common optimizers such as SGD, Adam, etc. under the optimizer module;
[0090] (5) Under the rlayer module, RConv1d, RConv2d, Rconv3d, RSequential, RWeightNorm, RMaxPoll, RMinPoll, RAvgPoll and other operators are included;
[0091] 4. User layer
[0092] The user layer provides an interface of each module for the user, so that the user can apply the application scenario according to the user's application scenario, the application scenario refers to the specific implementation task of the user, such as carrying out image classification task, local learning gradient derivation algorithm selection StrictPC, and the like. The network is created through the rlayer module, the data set is downloaded and loaded through the datasets module, the optimizer is created through the optimizer, the network loss and accuracy function are defined through the metrics, and the local learning derivation method is created and initialized through the grads, so that the network model training is realized. In addition, the application is an open system, and the user can encapsulate the own data set processing class, metric index, related operator and learning mechanism according to the respective requirement.
[0093] As shown in Figure 2 , it is a specific process of local learning, and the network definition, network creation, hyperparameter initialization and network training processes will be introduced through S1-S5.
[0094] Step S1 is a network definition process, and the user needs to call the corresponding operator through the rlayer module in Figure 1 to construct the own network.
[0095] Figure 2 Several types of local learning networks are shown, including: unidirectional network, bidirectional network and skip connection network, and the above several types of network topologies are only an example.
[0096] Figure 2 How to call the operator under the rlayer module to create the network topology defined in the red box in Figure 2 is also shown in detail, wherein the def setup (self) function includes instantiation of various operators, and the a_mat attribute needs to be used to specify the node connected with the operator during the operator instantiation, and the def__call__(self,input) function is the forward calculation process of the entire network.
[0097] Step S2, network creation, hyperparameter initialization;
[0098] Step S201, network creation stage, the network defined in step S101 is instantiated to obtain the initialized network parameters.
[0099] Step S202, data set loading and normalization, the data set download, loading and preprocessing class under the datasets module in Figure 1 is called, the BatchSize is set, the data normalization method is loaded, and the training and testing data sets are loaded;
[0100] Step S203, the optimizer is created through calling Figure 1The optimizer module calls the corresponding optimizer class, such as Adam, to set the learning rate and corresponding parameters to complete the optimizer initialization;
[0101] Step S204: Create a local learning gradient derivative class by calling... Figure 1 In the `grads` module, the appropriate local learning gradient derivative class is selected. When instantiating the local learning gradient derivative class, the user selects the corresponding local learning method through the `mode` attribute to complete the instantiation of the gradient derivative class. Alternatively, the user can select the appropriate method through... Figure 1 The grads module includes a local learning base class LocalBase with custom energy functions, state updates, gradient calculation interfaces, and custom local learning algorithms.
[0102] Step S3: After completing network creation and hyperparameter initialization, perform energy calculation, state update, and gradient calculation.
[0103] Step S301: Traverse each instantiated operator in the network and store the operator's a_mat, operation, forward computation process, backward computation process, and model parameters of the layer into a matrix adj_mat (as shown in Formula 1), which will be used for subsequent energy function calculation, state update, gradient calculation, and other operations.
[0104]
[0105] in Describe edge f i The forward computation process, Describe edge f i The reverse calculation process, Storage and edge f i Connected node IDs Used to store the IDs of the preceding nodes adjacent to the edge and the operations involved. Describe edge f i The parameters.
[0106] Step S30101: Obtain the network instantiation object, traverse all the attributes of the object, determine whether the attribute is an instantiation object inherited from the parent class Module, if so, obtain the forward and backward calculation process, a_mat, operation attribute and the parameters corresponding to the operator in the object, and store them in a list adj_mat.
[0107] Step S302: Calculate the network energy based on the energy function;
[0108] Step S30201: Traverse adj_mat, perform network forward computation, and initialize network node states;
[0109] Step S30202, calculate the network energy, and derive the network node state to obtain the network node state change amount;
[0110] Step S30203, update the network node state according to the initialized network node state and the network node state change amount;
[0111] Step S30204, repeat the execution of steps S30202-S30203 until the network reaches a steady state, and obtain the final network node state;
[0112] Step S303, calculate the network energy based on the final network node state, and derive the network parameter to obtain the network parameter gradient;
[0113] According to the instantiation of the local learning gradient derivation class and the different mode parameters, the network parameter gradient can be obtained by executing different method processes:
[0114] Step S30301, if the user selects the EP TWO_PHASE method, execute S3030101-S3030103 to obtain the network parameter gradient:
[0115] Step S3030101, execute S30202-S30204 to obtain the first stage network node state (steady state V1), calculate the network energy based on the steady state V1 and derive the network parameter to obtain the network parameter gradient g1;
[0116] Step S3030102, execute S30202-S30204 based on the steady state V1 to obtain the second stage network node state (steady state V2), calculate the network energy based on the steady state V2 and derive the network parameter to obtain the network parameter gradient g2;
[0117] Step S3030103, calculate the final network parameter gradient according to g1, g2;
[0118] Step S30302, if the user selects the EP THREE_PHASE method, execute S3030201-S3030204 to obtain the network parameter gradient:
[0119] Step S3030201, execute S30202-S30204 to obtain the first stage network node state (steady state V1), calculate the network energy based on the steady state V1 and derive the network parameter to obtain the network parameter gradient g1;
[0120] Step S3030202, introduce external energy function, based on steady state V1, execute S30202-S30204, get the second stage network node state (steady state V2), based on steady state V2, calculate network energy and derive network parameters, get network parameter gradient g2;
[0121] Step S3030203, introduce-beta*external energy function, based on steady state V1, execute S30202-S30204, get the third stage network node state (steady state V3), based on steady state V3, calculate network energy again and derive network parameters, get network parameter gradient g3;
[0122] Step S3030204, calculate the final network parameter gradient according to g3 and g2;
[0123] Step S30303, if the user selects PC STRICT, FIXEDPRED method, execute S3030301 to get network parameter gradient:
[0124] Step S3030301, execute S30202-S30204 to get network node state (steady state V1), based on steady state V1, calculate network energy and derive network parameters, get network parameter gradient as the final gradient of network parameters;
[0125] Step S30304, if the user selects BiPC method, execute S3030401 to get network parameter gradient:
[0126] Step S3030401, execute S30202-S30204, get network node state (steady state V1), based on steady state V1, calculate network energy and derive network parameters, get network parameter gradient as the final gradient of network parameters, the difference from S3030301 is that when calculating network energy, the state value of the reverse node also needs to be considered;
[0127] Step S4, use the optimizer instantiated in step S203 to update network parameters based on network parameter gradient, and perform next iteration training;
[0128] Step S5, constantly iterate S3-S4 until the network training reaches the convergence condition set by the user.
[0129] In summary, the present application encapsulates the existing deep learning operators based on JAX, adds a_mat and operation attributes, and adds a reverse calculation process. Users can create large-scale networks with any topology. The addition of skip connections in the network can alleviate problems such as gradient vanishing and gradient explosion, making large-scale local learning tasks possible. In addition, the present application provides energy function, state calculation and update, and gradient calculation and update interfaces as abstract interfaces. Users can inherit and rewrite them to implement more complex local learning tasks, or call existing local learning algorithm interfaces to implement corresponding local learning tasks. The interface is simple to use and highly extensible, and can meet any type of local learning scenario. The instant compilation technique is introduced. The local learning task process only needs to be compiled once, and the process is converted into machine code and stored in the cache. Then the machine code is loaded and executed multiple times to implement local learning model training and inference, greatly improving network training efficiency and reducing network training time.
[0130] The present application has the following technical effects:
[0131] 1. Support for any network topology: Existing local learning methods can only support simple shallow deep learning networks and are difficult to support complex / deep networks. The present application rewrites the deep learning interface to effectively support users in creating networks with various topologies, greatly promoting the possibility of local learning for applications.
[0132] 2. Greatly improve network training and inference speed: The instant compilation technique is introduced to compile the training and inference process into Jaxpr. After XLA optimization, it is stored in the cache. The next time it is read directly from the cache, reducing the compilation and computation graph optimization time, greatly improving the network training and inference speed, and greatly reducing resource overhead.
[0133] 3. Simple and flexible user interface: Users can choose existing local learning algorithms or rewrite the energy function and state update interface to implement their own local learning method. In addition, due to the large difference between network node state, network parameter update method and backpropagation algorithm, the threshold for deep learning users to learn local learning is relatively high. Therefore, the present application takes this scenario into deep consideration when designing the system, allowing deep learning users to seamlessly transition to local learning.
[0134] 4. Support for data parallelism, parameter and state update parallelism: Reduce the training and inference time of large-scale local learning networks and improve model efficiency.
[0135] The experimental verification of the present application is as follows:
[0136] 1. Experimental environment
[0137] Table 1 Hardware Configuration Table
[0138]
[0139]
[0140] Table 2 Hardware configuration table
[0141]
[0142] 2、Experimental results
[0143] The experimental data (model accuracy, model loss, training time) of various local learning on the application and PyTorch are compared. Among them, the model accuracy and model loss of the application are close to or exceed the experimental results of PyTorch. In terms of training time, the network training speed of the application on the tasks of StrictPC, BiPC and EP THREE_PHASE is about 7, 2 and 3 times that of PyTorch, respectively.
[0144] The application further discloses an electronic device with computing capability. The electronic device comprises a memory and a processor, and the memory stores a computer program. When the processor executes the computer program, the steps of the above-mentioned efficient local learning method supporting an arbitrary network topology are realized. The processor can be a CPU, a GPU or a BCU.
[0145] Figure 5 A structural diagram of an electronic device according to an embodiment of the application is shown in FIG. 1. Figure 5 As shown in FIG. 1, the electronic device comprises a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. The processor of the electronic device is used to provide computing and control capability. The memory of the electronic device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the electronic device is used to perform wired or wireless communication with an external terminal. The wireless communication can be realized through WIFI, an operator network, near field communication (NFC) or other technologies. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen. The input device of the electronic device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the electronic device, or an external keyboard, touchpad or mouse, etc.
[0146] Those skilled in the art can understand that, Figure 5The structure shown in the figures is only a structural diagram of part of the technical solution of the present disclosure, and does not constitute a limitation on the electronic device to which the technical solution of the present application is applied. The specific electronic device can include more or fewer components than those shown in the figures, or combine certain components, or have a different arrangement of components.
[0147] The application further discloses a computer readable storage medium. The computer readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the high-efficiency local learning method supporting an arbitrary network topology are implemented.
[0148] Please note that the technical features of the above embodiments can be combined in any manner. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combinations of the technical features do not contradict, they should be considered as the scope of the present disclosure. The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be considered as a limitation on the scope of the patent. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, some modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of the patent of the present application should be subject to the appended claims.
Claims
1. A high-efficiency local learning system supporting arbitrary network topology, applied to various local learning tasks, realized by an electronic device with computing capability, characterized in that, The system comprises a module layer and an operator layer; wherein, The modules encapsulated by the module layer comprise: rlayer modules, datasets modules, grads modules, metrics modules, and optimizer modules; wherein, The rlayer modules comprise a plurality of operators for creating a network, at least comprising: convolution operators, pooling operators, and normalization operators; The datasets modules comprise a plurality of classes for downloading, loading, and preprocessing public datasets; The grads modules comprise a plurality of local learning derivation classes; The metrics modules comprise a plurality of deep learning measurement indicators; The optimizer modules comprise a plurality of optimizers; The operator classes, gradient derivation classes, optimizer classes, dataset classes, and measurement indicator functions encapsulated by the operator layer correspond to the modules encapsulated by the module layer, and are used for providing interfaces of the modules encapsulated by the module layer, comprising: Corresponding to the rlayer modules, at least encapsulating: RConv1d operators, RConv2d operators, Rconv3d operators, RSequential operators, RWeightNorm operators, RMaxPoll operators, RMinPoll operators, and RAvgPoll operators; Corresponding to the datasets modules, at least encapsulating: MNIST, CIFAR10, and CIFAR100 dataset download and preprocessing classes; Corresponding to the grads modules, at least encapsulating: PC local learning gradient derivation classes, BiPC local learning gradient derivation classes, and EP local learning gradient derivation classes; in addition, the gradient derivation base class LocalBase is also included, and users can rewrite corresponding methods according to their own needs to realize their local learning derivation classes; corresponding to the metrics modules, at least encapsulating: model accuracy calculation functions and loss calculation functions; Corresponding to the optimizer modules, at least encapsulating: Adam optimizers and SGD optimizers; The operator classes, dataset download and preprocessing classes, optimizer classes, gradient derivation classes, and indicator calculation functions encapsulated by the module layer all have input and output interfaces, users can create and instantiate a network as needed through the rlayer modules, download and preprocess corresponding datasets through the datasets modules, select corresponding optimizers through the optimizer modules, select local learning gradient derivation classes through the grads modules, and select loss and accuracy calculation functions through the metrics modules, to complete initialization of the network and corresponding hyperparameters, and realize network training and testing.
2. The system for efficient local learning supporting arbitrary network topology of claim 1, wherein, The local learning method at least comprises: StrictPC, FixedPredPC, BiPC, EP two phase, and EP three phase.
3. The system for efficient local learning supporting arbitrary network topology of claim 1, wherein, The processor of the electronic device is: a CPU, a GPU, or a BCU.
4. The system for efficient local learning supporting arbitrary network topology of claim 1, wherein, The network structure is defined as: the operator calculation flow is the edge, and the output of the operator is the node; the operator includes a_mat attribute and operation attribute, wherein the a_mat attribute is used for storing the node ID connected with the edge, and the operation attribute is used for storing the operation involved by the previous node adjacent to the edge; the network structure form at least includes: one-way network, two-way network and skip network.
5. A method for efficient local learning supporting arbitrary network topology, characterized in that, The method is implemented by the high-efficiency local learning system supporting arbitrary network topology as claimed in any one of claims 1-4, and the method comprises the following steps: Step 1, constructing the network required by the user by calling multiple operators through the rlayer module; Step 2, instantiating the created network and setting various hyperparameters; specifically including: Step 21, instantiating the created network to obtain network parameters; Step 22, calling the dataset download, loading and preprocessing class under the datasets module, setting BatchSize, and performing data normalization on the loaded training dataset and test dataset; Step 23, calling the optimizer module, selecting an optimizer, and setting the learning rate to complete the initialization of the selected optimizer; Step 24, calling the grads module, selecting a local learning gradient derivation class; Step 3, based on the instantiated network and hyperparameters, performing network energy solving, state updating and gradient calculation; specifically including: Step 31, traversing each instantiated operator in the network to obtain all attributes of the operator, judging whether the attribute is inherited from the instantiation object of the parent class Module, if yes, obtaining the forward and reverse calculation process, a_mat, operation attribute and network parameters corresponding to the operator, and storing them in a list adj_mat for energy function calculation, state updating and gradient calculation operation; Step 32, calculating the network energy according to the energy function to obtain the final network node state; Step 33, calculating the network energy according to the obtained final network node state, and deriving the network parameters to obtain the network parameter gradient; Step 4, updating the network parameters based on the network parameter gradient for next iteration training; Step 5, constantly iterating steps 3-4 until the network training reaches the convergence condition set by the user.
6. The method of claim 5, wherein, Step 32 specifically includes: Step 321, traversing adj_mat to perform model forward calculation and initialize network node state; Step 322, calculating the network energy according to the energy function, and deriving the network node state to obtain the network node state change; Step 323, updating the network node state according to the initialized network node state and network node state change; Step 324, repeatedly executing steps 322-323 until the network node state reaches a steady state to obtain the final network node state.
7. The method of claim 6, wherein, Step 33 specifically includes: when the user selects the EP two phase as the derivation method, the following steps are executed to obtain the network parameter gradient: Step 3311, the network node state of the first stage is obtained by performing 322-324, the network node state of the first stage is recorded as steady state V1, the network energy is calculated based on the steady state V1, and the network parameters are derived to obtain the network parameter gradient g1; Step 3312, the network node state of the second stage is obtained by performing 322-324 based on the steady state V1, the network node state of the second stage is recorded as steady state V2, the network energy is calculated based on the steady state V2, and the network parameters are derived to obtain the network parameter gradient g2; Step 3313, the final network parameter gradient is calculated according to g1 and g2.
8. The method of claim 6, wherein the method is characterized by, Step 33 is specifically: when the user selects the local learning derivation method as the EP three phase method, the following steps are performed to obtain the network parameter gradient: Step 3321, the network node state of the first stage is obtained by performing 322-324, the network node state of the first stage is recorded as steady state V1, the network energy is calculated based on the steady state V1, and the network parameters are derived to obtain the network parameter gradient g1; Step 3322, an external energy function is introduced, the network node state of the second stage is obtained by performing 322-324 based on the steady state V1, the network node state of the second stage is recorded as steady state V2, the network energy is calculated based on the steady state V2, and the network parameters are derived to obtain the network parameter gradient g2; Step 3323, an external energy function is introduced, the network node state of the second stage is obtained by performing 322-324 based on the steady state V1, the network node state of the second stage is recorded as steady state V2, the network energy is calculated based on the steady state V2, and the network parameters are derived to obtain the network parameter gradient g2; Step 3324, the final network parameter gradient is calculated according to g3 and g2.
9. The method of claim 6, wherein the method is characterized by, Step 33 is specifically: when the user selects the local learning derivation method as StrictPC, FixedPredPC, the following steps are performed to obtain the network parameter gradient: the network node state is obtained by performing 322-324, the network node state is recorded as steady state V1, the network energy is calculated based on the steady state V1, and the network parameters are derived to obtain the network parameter gradient as the final gradient of the network parameters.
10. The method of claim 6, wherein the method is characterized by, Step 33 is specifically: when the user selects the local learning derivation method as BiPC, the following steps are performed to obtain the network parameter gradient: when calculating the network energy, the reverse node state in the network needs to be considered, step 322-324 is performed to obtain the network node state of the first stage, the network node state of the first stage is recorded as steady state V1, the network energy is calculated based on the steady state V1, and the network parameters are derived to obtain the network parameter gradient as the final gradient of the network parameters.
11. The method of claim 5, wherein the method is characterized by, The instant compilation and parallel technology are adopted to improve the network training and inference speed.
12. An electronic device, comprising: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor executes the computer program to implement the steps of the efficient local learning method supporting any network topology in any of claims 5-11.
13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to realize the steps in the high-efficiency local learning method supporting an arbitrary network topology according to any one of claims 5 to 11.
Citation Information
Patent Citations
Efficient deep learning model deployment framework
CN111240656A
Method of constructing network model for deep learning, device, and storage medium
US20220058490A1