Model training method and device, computer readable storage medium and electronic device
By acquiring historical model training information of nodes, the current model training scheme is determined, which solves the problem of task interruption when nodes are interrupted, and ensures the normal progress of joint learning tasks and efficient use of resources.
Patent Information
- Application Number
- CN202110040138.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-13
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2041-01-13
AI Technical Summary
When a node is interrupted during the execution of a joint learning task, there is a lack of effective model training methods, which prevents the task from proceeding normally.
By acquiring the historical model training information of multiple nodes, the current model training scheme is determined, ensuring that training can continue even when a node is interrupted without having to repeat the process from the initial state, thereby improving task processing efficiency and reducing resource waste.
When a node is interrupted, the current model training scheme can be determined in real time, ensuring the normal progress of the joint learning task, improving task processing efficiency and reducing resource waste.
Smart Images

Figure CN114764626B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of energy, in particular to a model training method and device, a computer readable storage medium and an electronic device. BACKGROUND
[0002] With the development of computer technology, in the process of performing a federated learning task, it is usually necessary to perform model training by multiple nodes respectively, then aggregate the local models obtained by the model training of the multiple nodes respectively to obtain an updated model, and then each node performs model training on the updated model to obtain a local model, and the above aggregation and model iteration process is repeated to obtain an updated model that meets the iteration condition, thereby realizing the federated learning task. However, there is currently a lack of a model training method when a node is interrupted. SUMMARY
[0003] The present application provides a model training method and device, a computer readable storage medium and an electronic device, which can determine a current model training scheme in real time when an interrupted node occurs in the process of performing a federated learning task, and ensure the normal progress of the federated learning task.
[0004] In a first aspect, the present application provides a model training method, comprising:
[0005] obtaining historical model training information of multiple nodes respectively in a preset time period before a current time in performing a federated learning task;
[0006] when there is an interrupted node among the multiple nodes, determining a current model training scheme of the multiple nodes according to the historical model training information of the multiple nodes respectively.
[0007] In an embodiment, the method further comprises:
[0008] obtaining an interruption reason of the interrupted node among the multiple nodes;
[0009] when the interruption reason of the interrupted node meets a preset condition, performing the step of determining the current model training scheme of the multiple nodes according to the historical model training information of the multiple nodes.
[0010] In an embodiment, the interruption reason of the interrupted node meeting the preset condition comprises the interruption reason of the interrupted node being non-active exit;
[0011] when the interruption reason of the interrupted node is active exit, deleting the interrupted node from the multiple nodes.
[0012] In an embodiment, the current model training scheme comprises federated learning according to model parameters of this iteration in the historical model training information of the non-interrupted nodes among the multiple nodes respectively.
[0013] In one embodiment, further comprising:
[0014] When the interrupt node is restored to normal, an actual recovery time point of the interrupt node is obtained, and the interrupt node is marked as a restored node;
[0015] A current global model corresponding to the actual recovery time point is obtained;
[0016] The current global model is sent to the restored node, so that the restored node performs model training on the current global model.
[0017] In one embodiment, the model training information includes model parameters obtained in the last iteration;
[0018] The current model training scheme includes joint learning according to model parameters in the last iteration in the historical model training information of each of the plurality of nodes.
[0019] In one embodiment, the determining of the current model training scheme of the plurality of nodes according to the historical model training information of the plurality of nodes comprises:
[0020] An interrupt time point corresponding to the interrupt node and a data weight corresponding to the interrupt node are obtained;
[0021] The current model training scheme of the plurality of nodes is determined according to the interrupt time point corresponding to the interrupt node, the data weight corresponding to the interrupt node, and the historical model training information corresponding to each of the plurality of nodes.
[0022] In one embodiment, the time interval between the interrupt time point and the interrupt time of the interrupt node is not greater than a preset time threshold, the data weight of the interrupt node is not greater than a preset weight threshold, and the current model training scheme includes joint learning according to model parameters in the current iteration in the historical model training information of each of the plurality of nodes.
[0023] In a second aspect, the present application provides a model training device, comprising:
[0024] The obtaining module is configured to obtain historical model training information within a preset time period before a current time of each of a plurality of nodes in performing a joint learning task;
[0025] The scheme determining module is configured to, when there is an interrupt node in the plurality of nodes, determine a current model training scheme of the plurality of nodes according to the historical model training information of each of the plurality of nodes.
[0026] In a third aspect, the present application provides a computer readable storage medium comprising execution instructions, when a processor of an electronic device executes the execution instructions, the processor executes the method according to any one of the first aspect.
[0027] In a fourth aspect, the present application provides an electronic device comprising a processor and a memory storing execution instructions, when the processor executes the execution instructions stored in the memory, the processor executes the method according to any one of the first aspect.
[0028] The present application provides a model training method and device, a computer readable storage medium and an electronic device. The method obtains historical model training information of each node in a preset time period before the current time of each node in a joint learning task, and then, when there is an interrupted node in the plurality of nodes, determines a current model training scheme of the plurality of nodes according to the historical model training information corresponding to each node. In summary, the present application can determine a current model training scheme in real time when an interrupted node occurs in the joint learning task, and ensure the normal progress of the joint learning task.
[0029] The further effects of the above-described preferred but non-conventional modes will be described in the following in connection with the specific embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present application or the prior art technical solutions, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings described below are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0031] Figure 1 A flowchart of a model training method provided by an embodiment of the present application;
[0032] Figure 2 A structural diagram of a model training device provided by an embodiment of the present application;
[0033] Figure 3 A structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0034] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0035] like Figure 1 The illustration shows a model training method provided by an embodiment of the present invention. The method provided by this embodiment can be applied to electronic devices, specifically servers or general computers. This embodiment describes the method using an electronic device as the execution subject. Specifically, the method includes the following steps:
[0036] Step 101: Obtain the historical model training information of each of the multiple nodes in the joint learning task within a preset time period before the current time.
[0037] Understandably, historical model training information includes model parameters from the training process. For example, when the model is a neural network, the training information includes parameters such as weights, the epoch of the current sample, the current batch size, and gradients. Similarly, when the model is a gradient descent tree, it records the ID of each tree, the node ID of each node, the optimal split feature ID, the optimal split feature value ID, and leaf node information. It should also be understood that historical model training information includes model training information from a pre-defined time period prior to the current moment. The end time of the pre-defined time period is the current moment, and the pre-defined time period should at least include the model parameters obtained from the previous iteration.
[0038] Specifically, the joint learning task can be a horizontal joint learning task or a vertical joint learning task. The horizontal joint learning task can be a horizontal improvement decision tree task.
[0039] This embodiment also includes:
[0040] Obtain the heartbeat information of each of the multiple nodes, the heartbeat information indicating whether the network is online;
[0041] Based on the heartbeat information of each of the multiple nodes, determine whether there is an interrupted node among the multiple nodes.
[0042] Specifically, for each node, the node is subjected to heartbeat detection according to heartbeat information corresponding to the node, and the network state of the node can be determined through the heartbeat detection. When the network of the node is interrupted, the node can be considered to be interrupted. The heartbeat detection refers to that a sender sends a fixed format message to a receiver according to certain rules (periodic sending, idle sending, etc.), and the receiver replies a fixed format message after receiving the message. If no message is received for a long time, for example, 3 times of the heartbeat period, it is considered that the current connection is invalid. Specifically, the heartbeat information can include network traffic.
[0043] Step 102, when there is an interrupted node in the plurality of nodes, determining a current model training scheme of the plurality of nodes according to historical model training information of the plurality of nodes respectively.
[0044] In the embodiment, when a node is interrupted, the joint learning task can be continued from the interrupted node without repeating execution from the initial state, thereby improving task processing efficiency and reducing resource waste.
[0045] In one embodiment, the method further comprises:
[0046] Obtaining an interruption reason of the interrupted node in the plurality of nodes.
[0047] When the interruption reason of the interrupted node meets a preset condition, the step of determining the current model training scheme of the plurality of nodes according to the historical model training information of the plurality of nodes is executed.
[0048] In the embodiment, by obtaining the interruption reason of the interrupted node in the plurality of nodes, whether the interrupted node can join the joint learning task from the middle when the interrupted node is recovered is known. When the interrupted node can join the joint learning task from the middle, the current model training scheme of the plurality of nodes is determined according to the historical model training information of the plurality of nodes respectively.
[0049] Specifically, the interruption reason of the interrupted node meeting the preset condition includes that the interruption reason of the interrupted node is non-active exit. The non-active exit can be caused by network reasons, and therefore, the training can be continued after the network is recovered.
[0050] Specifically, when the interruption reason of the interrupted node is active exit, the interrupted node is deleted from the plurality of nodes. The active exit is usually caused by the user wanting to interrupt the training, and therefore, the interrupted node is deleted from the plurality of nodes, and the training can be continued through the nodes that are not interrupted.
[0051] In some possible implementation manners, the determining the current model training scheme of the plurality of nodes according to the historical model training information of the plurality of nodes comprises:
[0052] obtaining a recoverable time point corresponding to the interrupted node and a data weight corresponding to the interrupted node;
[0053] determining a current model training scheme of the plurality of nodes according to the recoverable time point corresponding to the interrupted node, the data weight corresponding to the interrupted node, and historical model training information corresponding to each of the plurality of nodes.
[0054] In this embodiment, the recoverable time point corresponding to the interrupted node can be predicted, and the data weight of the interrupted node can be obtained. Then, according to the recoverable time point corresponding to the interrupted node, the data weight corresponding to the interrupted node, and historical model training information corresponding to each of the plurality of nodes, a current model training scheme of the plurality of nodes is determined.
[0055] Optionally, the user corresponding to the interrupted node is informed of the interruption cause of the interrupted node, and feedback of the recoverable time point of the user is received. According to the feedback of the recoverable time point of the user and historical interruption records of the user, the recoverable time point of the interrupted node is predicted. According to the data amount of the interrupted node for performing the joint learning task, the data weight corresponding to the interrupted node is determined.
[0056] Optionally, a time interval between the recoverable time point and an interruption time of the interrupted node is not greater than a preset time threshold, the data weight of the interrupted node is not greater than a preset weight threshold, and the current model training scheme includes joint learning according to model parameters of this iteration in the historical model training information of each of the plurality of nodes. The preset time threshold refers to the shortest time for judging that the interruption time has less influence on model training. When the time interval between the recoverable time point and the interruption time point of the interrupted node is not greater than the preset time threshold, it is indicated that the interruption time is short. The preset weight threshold refers to the minimum weight for judging that the joint learning is not greatly affected. When the data weight of the interrupted node is not greater than the preset weight threshold, it is indicated that the interrupted node has little influence on the joint learning. At this time, joint learning can be performed based on the model parameters of this iteration of each of the plurality of nodes, in other words, the plurality of nodes can be normally trained.
[0057] Optionally, a time interval between the recoverable time point and the interrupt time of the interrupt node is not less than a preset weight threshold, a data weight of the interrupt node is greater than the preset weight threshold, the historical model training information includes model parameters obtained in a previous iteration, and the current model training scheme includes joint learning according to the model parameters obtained in the previous iteration of each of the plurality of nodes. When the time interval between the recoverable time point and the interrupt time of the interrupt node is not less than the preset time threshold, it indicates that the interrupt time is relatively long, and the data weight of the interrupt node is not less than the preset weight threshold, which indicates that the interrupt node has a greater impact on joint learning. In order to ensure the execution effect of the joint learning task, it is necessary to re-iterate, and at this time, joint learning can be performed according to the model parameters obtained in the previous iteration of each of the plurality of nodes.
[0058] It should be noted that the current iteration refers to the iteration number corresponding to the current time, and the previous iteration refers to the iteration before the current iteration. The iteration number carried by the current iteration minus 1 is the iteration number of the previous iteration.
[0059] In one embodiment, the current model training scheme includes joint learning according to the model parameters of the current iteration in the historical model training information of each of the non-interrupt nodes in the plurality of nodes.
[0060] In order to ensure the execution effect of the joint learning task, the model training method includes joint learning according to the model parameters of the current iteration of each of the non-interrupt nodes in the plurality of nodes. In other words, the nodes that do not interrupt can be trained normally.
[0061] For example, the joint learning task is a horizontal joint learning task, and the current model training scheme includes horizontal joint learning through the non-interrupt nodes in the plurality of nodes. Horizontal joint learning through the non-interrupt nodes in the plurality of nodes can ensure the smooth execution of the joint learning task. It should be noted that each of the plurality of nodes performs horizontal joint learning in a non-cluster environment.
[0062] Further, it also includes:
[0063] When the interrupt node recovers normally, an actual recovery time point of the interrupt node is obtained, and the interrupt node is marked as a recovered node;
[0064] A current global model corresponding to the actual recovery time point is obtained.
[0065] The current global model is sent to the recovered node, so that the recovered node performs model training on the current global model.
[0066] In this embodiment, when the interrupted node recovers, the interrupted node is marked as a recovered node, and the recovered node is involved in the federated learning from the current global model. Here, the current global model can be understood as the global model closest to the actual recovery time point in terms of the model generation time point, in other words, the global model last received by the plurality of nodes from the federated learning control end.
[0067] In one embodiment, the model training information includes model parameters obtained in the previous iteration;
[0068] The current model training scheme includes federated learning according to the model parameters of the previous iteration in the historical model training information of each of the plurality of nodes.
[0069] In order to ensure the execution effect of the federated learning task, the model training method includes federated learning according to the model parameters of the previous iteration of each of the plurality of nodes. In other words, this iteration is restarted after the previous iteration ends.
[0070] For example, the federated learning task is a horizontal boosting decision tree task; the historical model training information includes a regression tree of the previous iteration, and the current model training scheme includes simultaneously iterating the plurality of nodes from the time when the training of the regression tree of the previous iteration of each of the plurality of nodes ends.
[0071] For example, the federated learning task is a vertical federated learning task; the historical model training information includes a sample round or batch of the previous iteration, and the current model training scheme includes simultaneously iterating the plurality of nodes from the time when the record of the sample round or batch of the previous iteration of each of the plurality of nodes ends.
[0072] From the above technical solutions, it can be seen that the embodiment has the following beneficial effects:
[0073] When an interrupted node occurs during the execution of the federated learning task, the current model training scheme can be determined in real time, and the normal execution of the federated learning task is ensured.
[0074] Based on the same concept as the method embodiment of the present application, please refer to Figure 2 The embodiment of the present application also provides a model training device, which comprises:
[0075] The acquisition module 201 is configured to acquire historical model training information within a preset time period before the current time of each of the plurality of nodes in the execution of the federated learning task;
[0076] The scheme determination module 202 is configured to, when there is an interrupted node in the plurality of nodes, determine a current model training scheme of the plurality of nodes according to the historical model training information of each of the plurality of nodes.
[0077] In one embodiment, further comprising: a cause determining module and an executing module; wherein
[0078] The cause determining module is configured to acquire an interrupt cause of an interrupt node in the plurality of nodes.
[0079] The executing module is configured to execute the determination of the current model training scheme of the plurality of nodes according to the historical model training information of the plurality of nodes respectively when the interrupt cause of the interrupt node meets a preset condition.
[0080] In one embodiment, the interrupt cause of the interrupt node meeting the preset condition comprises that the interrupt cause of the interrupt node is a non-active exit.
[0081] In one embodiment, when the interrupt cause of the interrupt node is an active exit, the interrupt node is deleted from the plurality of nodes.
[0082] In one embodiment, the current model training scheme comprises joint learning according to model parameters of this iteration in the historical model training information of the non-interrupt node in the plurality of nodes respectively.
[0083] In one embodiment, further comprising: a marking module, a model determining module and a training module; wherein,
[0084] The marking module is configured to acquire an actual recovery time point of the interrupt node when the interrupt node recovers normally, and mark the interrupt node as a recovered node.
[0085] The model determining module is configured to acquire a current global model corresponding to the actual recovery time point.
[0086] The training module is configured to send the current global model to the recovered node, so that the recovered node performs model training on the current global model.
[0087] In one embodiment, the model training information comprises model parameters obtained in a previous iteration; and the current model training scheme comprises joint learning according to the model parameters of the previous iteration in the historical model training information of the plurality of nodes respectively.
[0088] In one embodiment, the scheme determining module 202 comprises: an acquiring unit and a scheme determining unit; wherein,
[0089] The acquiring unit is configured to acquire a recoverable time point corresponding to the interrupt node and a data weight corresponding to the interrupt node.
[0090] The scheme determination unit is used to determine the current model training scheme of the multiple nodes based on the recoverable time point corresponding to the interrupted node, the data weight corresponding to the interrupted node, and the historical model training information corresponding to each of the multiple nodes.
[0091] In one embodiment, the time interval between the recoverable time point and the interruption time of the interruption node is not greater than a preset time threshold, the data weight of the interruption node is not greater than a preset weight threshold, and the current model training scheme includes joint learning based on the model parameters of the current iteration in the historical model training information of each of the multiple nodes.
[0092] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. At the hardware level, the electronic device includes a processor 301 and a memory 302 storing execution instructions, and optionally also includes an internal bus 303 and a network interface 304. The memory 302 may include main memory 3021, such as high-speed random-access memory (RAM), and may also include non-volatile memory 3022, such as at least one disk storage device. The processor 301, network interface 304, and memory 302 can be interconnected via the internal bus 303, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The internal bus 303 can be divided into an address bus, a data bus, a control bus, etc., for ease of representation. Figure 3 The symbol is represented by only one double-headed arrow, but this does not mean that there is only one bus or one type of bus. Of course, the electronic device may also include other hardware required for other services. When processor 301 executes the execution instructions stored in memory 302, processor 301 executes the method in any embodiment of the present invention, and is at least used to perform tasks such as... Figure 1 The method shown.
[0093] In one possible implementation, the processor reads the corresponding execution instructions from non-volatile memory into main memory and then executes them. Alternatively, it may obtain the corresponding execution instructions from other devices to form a model training device at the logical level. The processor executes the execution instructions stored in the memory to implement a model training method provided in any embodiment of the present invention through the executed instructions.
[0094] The processor can be an integrated circuit chip having a processing capability of signals. In the implementation process, each step of the above method can be completed by integrated logic circuits of hardware in the processor or instructions in the form of software. The processor described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. Each method, step and logic block diagram disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor.
[0095] The embodiment of the present application further provides a computer readable storage medium, including execution instructions, when a processor of an electronic device executes the execution instructions, the processor executes the method provided in any one of the embodiments of the present application. The electronic device can be specifically the electronic device as shown in the figure; the execution instructions are a computer program corresponding to the model training device. Figure 3
[0096] Those skilled in the art should understand that the embodiments of the present application can be provided as a method or a computer program product. Therefore, the present application can adopt a complete hardware embodiment, a complete software embodiment, or a combination of software and hardware.
[0097] Each of the embodiments in the present application is described in a progressive manner, and the same or similar parts of each of the embodiments can be referred to each other. Each embodiment focuses on the difference from other embodiments. Especially, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the related parts can be referred to the part of the method embodiment.
[0098] It is also to be noted that the terms "comprising", "including", and any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises a... " does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the recited element.
[0099] The above description is only the preferred embodiment of the application, not intended to limit the application. Any modification, equivalent replacement and improvement made within the spirit and principle of the application shall fall within the scope of the claims of the application.
Claims
1. A model training method, characterized in that, The method comprises: obtaining historical model training information of each of a plurality of nodes in a preset time period before a current time point of performing a joint learning task; obtaining heartbeat information of each of the plurality of nodes, the heartbeat information indicating whether the network is online, performing heartbeat detection on the node according to the heartbeat information of each of the plurality of nodes to determine the network state of the node, and determining whether there is an interrupted node in the plurality of nodes according to the network states of the plurality of nodes; when there is an interrupted node in the plurality of nodes, obtaining an interruption cause of the interrupted node in the plurality of nodes, and deleting the interrupted node from the plurality of nodes when the interruption cause of the interrupted node is active exit; when the interruption cause of the interrupted node is not active exit, determining a current model training scheme of the plurality of nodes according to the historical model training information of each of the plurality of nodes; when the interrupted node returns to normal, obtaining an actual recovery time point of the interrupted node, and marking the interrupted node as a recovered node; obtaining a current global model corresponding to the actual recovery time point; sending the current global model to the recovered node to enable the recovered node to perform model training on the current global model.
2. The method of claim 1, wherein, The current model training scheme comprises joint learning according to model parameters of this iteration in the historical model training information of each of the non-interrupted nodes in the plurality of nodes.
3. The method of claim 1, wherein, The current model training scheme comprises joint learning according to model parameters of the previous iteration in the historical model training information of each of the plurality of nodes.
4. The method of claim 1, wherein, The determination of the current model training scheme of the plurality of nodes according to the historical model training information of the plurality of nodes comprises: obtaining a recoverable time point corresponding to the interrupted node and a data weight corresponding to the interrupted node; and determining the current model training scheme of the plurality of nodes according to the recoverable time point corresponding to the interrupted node, the data weight corresponding to the interrupted node, and the historical model training information corresponding to each of the plurality of nodes.
5. The method of claim 4, wherein, The time interval between the recoverable time point and the interruption time of the interrupted node is not greater than a preset time threshold, the data weight of the interrupted node is not greater than a preset weight threshold, and the current model training scheme comprises joint learning according to model parameters of this iteration in the historical model training information of each of the plurality of nodes.
6. A model training apparatus characterized by comprising: The method comprises: a obtaining module configured to obtain historical model training information of each of a plurality of nodes in a preset time period before a current time point of performing a joint learning task; a scheme determining module comprising a cause determining module and an executing module; the cause determining module is configured to obtain heartbeat information of each of the plurality of nodes, the heartbeat information indicating whether the network is online, perform heartbeat detection on the node according to the heartbeat information of each of the plurality of nodes to determine the network state of the node, and determine whether there is an interrupted node in the plurality of nodes according to the network states of the plurality of nodes; and when there is an interrupted node in the plurality of nodes, obtain an interruption cause of the interrupted node in the plurality of nodes. The execution module is configured to: when the interrupt cause of the interrupt node is active exit, delete the interrupt node from the plurality of nodes; and when the interrupt cause of the interrupt node is not active exit, determine a current model training scheme of the plurality of nodes according to historical model training information of the plurality of nodes. The model training device further comprises: A marking module configured to, when the interrupt node returns to normal, acquire an actual recovery time point of the interrupt node, and mark the interrupt node as a recovered node; A model determination module configured to acquire a current global model corresponding to the actual recovery time point; A training module configured to send the current global model to the recovered node, so that the recovered node performs model training on the current global model. 7.A computer-readable storage medium comprising execution instructions, when a processor of an electronic device executes the execution instructions, the processor executes the method in any one of claims 1 to 5.
Citation Information
Patent Citations
Distributed machine learning training method and device, computer equipment and storage medium
CN110852445A
Federated learning model training method and device
CN111950740A