A power stealing detection method and device based on decentralized federated learning and pruning
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-16
- Publication Date
- 2026-08-11
AI Technical Summary
[0004]但是这种方式,中央服务器与各边缘智能设备的高通信量限制了联邦学习框架的拓展性,中央服务器故障将导致整个训练过程的中断;除此之外,传统方法未考虑中央服务器的信任问题,将模型信息全部发送给可能不完全可靠的中央服务器,这可能引发用户隐私的潜在风险;同时,传统方法需要对模型参数进行大量的数据计算,效率低下、浪费资源
[0038]1. This method and device for detecting electricity theft based on decentralized federated learning and pruning constructs a decentralized federated learning framework, and the electricity consumption data of each power station in the decentralized federated learning framework are used to train the electricity theft detection model in sequence, eliminating the need for a central server, improving reliability and security, and solving the problems of unreliability of the central server, interruption and leakage of user privacy in the prior art.
Smart Images

Figure CN118643378B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of electricity theft detection, specifically relating to an electricity theft detection method and device based on decentralized federated learning and pruning. Background Technology
[0002] With the rapid development of smart grids, electricity theft has seriously impacted the stable operation of the power system. In recent years, research on electricity theft detection has increased significantly, and various machine learning algorithms have been applied. Machine learning methods utilize large amounts of existing data to train network models to improve detection efficiency. However, while improving the effectiveness of electricity theft detection, traditional machine learning methods have not fully considered the protection of user privacy.
[0003] Therefore, many studies have applied federated learning frameworks to electricity theft detection. In traditional centralized federated learning, the central server collaborates with various edge intelligent devices to train neural network models, and finally aggregates the network models on the central server to update the global model.
[0004] However, this approach limits the scalability of the federated learning framework due to the high communication volume between the central server and various edge intelligent devices, and a failure of the central server will cause the entire training process to be interrupted. In addition, traditional methods do not consider the trust issue of the central server, sending all model information to a potentially unreliable central server, which may pose a potential risk to user privacy. At the same time, traditional methods require a large amount of data calculation on model parameters, which is inefficient and wasteful of resources. Summary of the Invention
[0005] The purpose of this invention is to address the problems raised in the background art by proposing a method and apparatus for detecting electricity theft based on decentralized federated learning and pruning.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0007] This invention proposes a method for detecting electricity theft based on decentralized federated learning and pruning, comprising:
[0008] The acquired electricity consumption data is input into the trained electricity theft detection model, and the output shows whether the electricity consumption data indicates electricity theft. The electricity theft detection model includes a first convolutional layer, a first activation function, a second convolutional layer, a second activation function, a third convolutional layer, a third activation function, a fourth convolutional layer, a fourth activation function, a first fully connected layer, a fifth activation function, and a second fully connected layer, which are connected sequentially from data input to output.
[0009] The training process of the electricity theft detection model includes:
[0010] Construct a decentralized federated learning framework, wherein the decentralized federated learning framework includes K power stations;
[0011] The electricity consumption data of K power supply stations are used to train the electricity theft detection model in turn. Each training cycle of the electricity consumption data of K power supply stations is considered as one training cycle, and the training cycle is iterated.
[0012] For the first training round, the parameters of the electricity theft detection model are first initialized, and the parameters of the electricity theft detection model trained at the current power station are used as the initial parameters of the electricity theft detection model trained at the next power station.
[0013] For the remaining training rounds, the parameters of the electricity theft detection model completed in the previous training round are used as the initial parameters of the electricity theft detection model trained in the current round. In this round, the compression ratio of the electricity theft detection model trained at the current power station is calculated and it is determined whether the preset compression ratio has been reached. If the preset compression ratio has not been reached, the channel of the electricity theft detection model trained at the current power station is pruned according to the preset rules. Then, the parameters of the electricity theft detection model after channel pruning are used as the initial parameters of the electricity theft detection model trained at the next power station. If the preset compression ratio has been reached, the parameters of the electricity theft detection model trained at the current power station are directly used as the initial parameters of the electricity theft detection model trained at the next power station.
[0014] The training continues until the preset number of training rounds is reached, resulting in a well-trained electricity theft detection model.
[0015] Preferably, during the training of the electricity theft detection model at each power supply station, the update formula for the parameters of the electricity theft detection model is as follows:
[0016]
[0017] in,
[0018]
[0019] in, This represents the parameters of the electricity theft detection model trained at the k-th power station in the t-th round. Let represent the initial parameters of the electricity theft detection model trained at the k-th power station in the t-th round, and η represent the learning rate. Represents the classification cross-entropy loss function Regarding parameters The gradient, := indicates overwriting the previous value. This indicates that the parameters of the electricity theft detection model are initialized in the first training round. This represents the parameters of the electricity theft detection model trained at the (k-1)th power station in the t-th round. Let represent the parameters of the electricity theft detection model trained for the Kth power station in the (t-1)th round, where t represents the training round, T represents the total number of training rounds, and T > 1. This represents the parameters obtained after channel pruning for the electricity theft detection model trained at the (k-1)th power station in the t-th round.
[0020] Preferably, the compression ratio of the electricity theft detection model trained on the current power station is calculated using the following formula:
[0021]
[0022] Where r represents the compression ratio of the currently trained electricity theft detection model. This represents the parameters of the electricity theft detection model trained for the k-th power station in the t-th round. This represents the computational complexity of the electricity theft detection model trained for the k-th power station in the t-th round. This represents the parameters of the electricity theft detection model initialized in the first training round. This represents the computational cost of the electricity theft detection model initialized in the first training round.
[0023] Preferably, the process of pruning the channels of the electricity theft detection model trained on the current power station according to preset rules includes:
[0024] First, calculate the importance score of each channel in each layer of the trained electricity theft detection model for the current power station, using the following formula:
[0025]
[0026] Where Importance(i) represents the importance score of channel i, N i w represents the number of weights for channel i. ij This represents the j-th weight in channel i;
[0027] Then, within each layer of the structure, all channels are sorted from highest to lowest importance score, and the last M channels in the sorted channels are ranked according to a preset ratio. l Each channel is pruned, and the calculation formula is as follows:
[0028] M l =P×C l ×100%
[0029] Among them, M l This indicates that after sorting the channels in the l-th layer structure according to their importance scores from high to low, the final M-order sequence is... l Each channel is pruned, where P represents the preset ratio during the channel pruning process, and C... l This indicates the number of channels in the l-th layer structure.
[0030] Preferably, each activation function uses the ReLU activation function.
[0031] Preferably, an electricity theft detection device based on decentralized federated learning and model pruning includes:
[0032] A smart meter equipped with a trained electricity theft detection model is used to collect electricity consumption data and to detect whether the electricity consumption data contains electricity theft behavior. The electricity theft detection model includes a first convolutional layer, a first activation function, a second convolutional layer, a second activation function, a third convolutional layer, a third activation function, a fourth convolutional layer, a fourth activation function, a first fully connected layer, a fifth activation function, and a second fully connected layer, which are connected in sequence from data input to output.
[0033] The first module is used to construct a decentralized federated learning framework, wherein the decentralized federated learning framework includes K power stations, the electricity consumption data of the K power stations are obtained through K clients respectively, and the first module is also used to train the electricity theft detection model in turn with the electricity consumption data of the K power stations obtained by the K clients in turn, and to iterate the model by taking each turn of training with the electricity consumption data of the K power stations as a training round.
[0034] In the first training round, the first module is also used to initialize the parameters of the trained electricity theft detection model and to use the parameters of the trained electricity theft detection model of the current power station as the initial parameters of the trained electricity theft detection model of the next power station.
[0035] In the remaining training rounds, the first module is also used to use the parameters of the electricity theft detection model completed in the previous training round as the initial parameters of the electricity theft detection model trained in the current round. In the current round, it is used to calculate the compression ratio of the electricity theft detection model trained at the current power station and determine whether it has reached the preset compression ratio. If it has not reached the preset compression ratio, it is used to perform channel pruning on the electricity theft detection model trained at the current power station according to preset rules. Then, it is used to use the parameters of the electricity theft detection model after channel pruning as the initial parameters of the electricity theft detection model trained at the next power station. If it has reached the preset compression ratio, it is used to directly use the parameters of the electricity theft detection model trained at the current power station as the initial parameters of the electricity theft detection model trained at the next power station.
[0036] The first module is also used to preset the number of training rounds and to stop training the electricity theft detection model after the number of training rounds has been reached.
[0037] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0038] 1. This method and device for detecting electricity theft based on decentralized federated learning and pruning constructs a decentralized federated learning framework, and the electricity consumption data of each power station in the decentralized federated learning framework are used to train the electricity theft detection model in sequence, eliminating the need for a central server, improving reliability and security, and solving the problems of unreliability of the central server, interruption and leakage of user privacy in the prior art.
[0039] 2. This method and device for detecting electricity theft based on decentralized federated learning and pruning improves the training efficiency of the electricity theft detection model by pruning the channels, thereby enhancing the overall performance and computational efficiency of the model. Attached Figure Description
[0040] Figure 1 This is a schematic diagram of the training process of the electricity theft detection model in the electricity theft detection method and device based on decentralized federated learning and pruning of the present invention.
[0041] Figure 2 This is a schematic diagram of the training framework in the electricity theft detection method and device based on decentralized federated learning and pruning of the present invention;
[0042] Figure 3 The graph shows the changes in parameters and FLOPs of the model under different compression ratios of this invention.
[0043] Figure 4 This is a graph showing the performance variation of the model of the present invention under different compression ratios;
[0044] Figure 5 This is a graph showing the inference time variation of the model under different compression ratios of the present invention. Detailed Implementation
[0045] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0046] It should be noted that when a component is referred to as being "connected" to another component, it can be directly connected to the other component or there may be an intervening component. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the specification of this application is for the purpose of describing particular embodiments only and is not intended to limit the application.
[0047] like Figure 1-5As shown, in one embodiment, a method for detecting electricity theft based on decentralized federated learning and pruning includes:
[0048] The acquired electricity consumption data is input into the trained electricity theft detection model, and the output shows whether the electricity consumption data indicates electricity theft. The electricity theft detection model includes a first convolutional layer, a first activation function, a second convolutional layer, a second activation function, a third convolutional layer, a third activation function, a fourth convolutional layer, a fourth activation function, a first fully connected layer, a fifth activation function, and a second fully connected layer, which are connected sequentially from data input to output.
[0049] In this model, all activation functions use the ReLU activation function, and all convolutional layers are 1D convolutional layers. The number of convolutional kernels, kernel size, and dilation coefficient of each convolutional layer in the electricity theft detection model are shown in Table 1.
[0050] Table 1
[0051]
[0052] The training process for the electricity theft detection model includes:
[0053] Step 1: Construct a decentralized federated learning framework, which includes K power stations (each power station supplies power to a corresponding user, and each power station records the user's electricity consumption data, and labels and classifies the electricity consumption data to indicate whether there is electricity theft). A schematic diagram of the decentralized federated learning framework is shown below. Figure 2 As shown, where Figure 2 In the diagram, the labels 1...K represent K power supply stations. The power supply stations labeled 1...K take turns training the electricity theft detection model, and each training iteration of a power supply station labeled 1...K is considered a training round t. The training is iterated until the preset number of training rounds is reached. Figure 2 The arrows between the power stations indicate that the parameters of the electricity theft detection model trained at the current power station are passed to the electricity theft detection model trained at the next power station as initial parameters.
[0054] Step 2: Train the electricity theft detection model sequentially using the electricity consumption data from the K power stations. Each training iteration of the K power stations' electricity consumption data constitutes one training round, and the training rounds are iterated. Simultaneously, pre-set the number of training rounds to T (in this embodiment, T > 1, e.g., T = 10), and operate within each training round as follows:
[0055] Step 2.1: For the first training round, first initialize the parameters of the electricity theft detection model (to...). Furthermore, the parameters of the electricity theft detection model trained at the current power station are used as the initial parameters for the electricity theft detection model trained at the next power station.
[0056] Step 2.2: For the remaining training rounds, use the parameters of the electricity theft detection model completed in the previous training round as the initial parameters of the electricity theft detection model trained in this round (i.e., use the parameters of the electricity theft detection model trained on the last power station in the previous training round as the initial parameters of the electricity theft detection model trained on the first power station in this training round; if the electricity theft detection model trained on the last power station in the previous training round underwent channel pruning, then use the pruned parameters as the initial parameters of the electricity theft detection model trained on the first power station in this training round). Furthermore, in this round, for the current power station... The compression ratio of the trained electricity theft detection model is calculated and it is determined whether the preset compression ratio has been reached. If the preset compression ratio has not been reached (the preset compression ratio R is set based on experience, and r < R in this case), the channel of the electricity theft detection model trained at the current power station is pruned according to the preset rules. Then the parameters of the electricity theft detection model after channel pruning are used as the initial parameters of the electricity theft detection model trained at the next power station. If the preset compression ratio is reached (i.e. r ≥ R), the parameters of the electricity theft detection model trained at the current power station are directly used as the initial parameters of the electricity theft detection model trained at the next power station.
[0057] During the training of the electricity theft detection model at each power supply station, the update formula for the parameters of the electricity theft detection model is as follows:
[0058]
[0059] in,
[0060]
[0061] in, And t=1 indicates that in the first training round, the initial parameters of the electricity theft detection model trained for the first power station are:
[0062] And t=1 means that in the first training round, the initial parameters of the electricity theft detection model trained for power stations other than the first power station are the parameters of the electricity theft detection model trained for the previous power station.
[0063] And 1 < t ≤ T means that in the remaining training rounds, the initial parameters of the first power station are the parameters of the electricity theft detection model trained in the previous training round;
[0064] And 1 < t ≤ T means that in the remaining training rounds, the initial parameters of the electricity theft detection model trained for power stations other than the first power station are the parameters obtained after channel pruning of the electricity theft detection model trained for the previous power station.
[0065] in, This represents the parameters of the electricity theft detection model trained at the k-th power station in the t-th round. Let represent the initial parameters of the electricity theft detection model trained at the k-th power station in the t-th round, and η represent the learning rate. Represents the classification cross-entropy loss function Regarding parameters The gradient, the loss function is calculated by comparing the training detection results with the labels, and := indicates overwriting the previous values. This indicates that the parameters of the electricity theft detection model are initialized in the first training round. This represents the parameters of the electricity theft detection model trained at the (k-1)th power station in the t-th round. Let represent the parameters of the electricity theft detection model trained for the Kth power station in the (t-1)th round, where t represents the training round, T represents the total number of training rounds, and T > 1. This represents the parameters obtained after channel pruning for the electricity theft detection model trained at the (k-1)th power station in the t-th round.
[0066] The compression ratio of the currently trained electricity theft detection model for the power station is calculated using the following formula:
[0067]
[0068] Where r represents the compression ratio of the currently trained electricity theft detection model. This represents the parameters of the electricity theft detection model trained for the k-th power station in the t-th round. This represents the computational complexity of the electricity theft detection model trained for the k-th power station in the t-th round. This represents the parameters of the electricity theft detection model initialized in the first training round (i.e., the initial parameters of the electricity theft detection model trained for the first power station in the first training round). This represents the computational cost of the electricity theft detection model initialized in the first training round. The specific computational cost of the model can be obtained through calculation. The specific calculation process is existing technology in this field and will not be described in detail in this invention.
[0069] Among these measures, the channel pruning of the currently trained electricity theft detection model at the power station is performed according to preset rules, including:
[0070] First, calculate the importance score of each channel in each layer of the trained electricity theft detection model for the current power station, using the following formula:
[0071]
[0072] Where Importance(i) represents the importance score of channel i, N i w represents the number of weights for channel i. ij This represents the j-th weight in channel i;
[0073] Then, within each layer of the structure, all channels are sorted from highest to lowest importance score, and the last M channels in the sorted channels are ranked according to a preset ratio. l Each channel is pruned, and the calculation formula is as follows:
[0074] M l =P×C l ×100%
[0075] Among them, M l This indicates that after sorting the channels in the l-th layer structure according to their importance scores from high to low, the final M-order sequence is... l Each channel is pruned, where P represents the preset ratio during the channel pruning process (which can be preset based on experience), and C... l This indicates the number of channels in the l-th layer structure.
[0076] Step 3: Continue until the preset number of training rounds is reached to obtain a trained electricity theft detection model.
[0077] In another embodiment, an electricity theft detection device based on decentralized federated learning and model pruning includes:
[0078] A smart meter equipped with a trained electricity theft detection model is used to collect electricity consumption data and to detect whether the electricity consumption data contains electricity theft behavior. The electricity theft detection model includes a first convolutional layer, a first activation function, a second convolutional layer, a second activation function, a third convolutional layer, a third activation function, a fourth convolutional layer, a fourth activation function, a first fully connected layer, a fifth activation function, and a second fully connected layer, which are connected sequentially from data input to output.
[0079] The first module is used to construct a decentralized federated learning framework, which includes K clients. The electricity consumption data of K power stations are obtained through the K clients (the K clients correspond one-to-one with the K power stations). The first module is also used to train the electricity theft detection model in turn with the electricity consumption data of the K power stations obtained by the K clients, and to iterate the model by training the electricity consumption data of the K power stations once in turn.
[0080] In the first training round, the first module is also used to initialize the parameters of the trained electricity theft detection model and to use the parameters of the trained electricity theft detection model of the current power station as the initial parameters of the trained electricity theft detection model of the next power station.
[0081] In the remaining training rounds, the first module is also used to use the parameters of the electricity theft detection model completed in the previous training round as the initial parameters of the electricity theft detection model trained in the current round. In the current round, it is used to calculate the compression ratio of the electricity theft detection model trained at the current power station and determine whether it has reached the preset compression ratio. If the preset compression ratio has not been reached, the electricity theft detection model trained at the current power station is pruned according to preset rules. Then, the parameters of the electricity theft detection model after the channel pruning are used as the initial parameters of the electricity theft detection model trained at the next power station. If the preset compression ratio has been reached, the parameters of the electricity theft detection model trained at the current power station are used directly as the initial parameters of the electricity theft detection model trained at the next power station.
[0082] The first module is also used to preset the number of training rounds and to stop training the electricity theft detection model after the number of training rounds has been reached.
[0083] It should be noted that the limitations of the method in this invention also apply to the apparatus, and will not be described again.
[0084] To more intuitively demonstrate the impact of the method of this invention on the performance of the electricity theft detection model, a comparative experiment was designed for the electricity theft detection model under different compression ratios. For example... Figure 3-5 As shown, the horizontal axis represents different compression ratios, and the vertical axis represents the corresponding performance values; from Figure 4 , Figure 5 It can be seen that although the compression ratio of the model increases, the number of parameters and FLOPs of the performance model decreases, while the accuracy (Acc) and AUC (an existing technique, mainly used to evaluate classifiers, defined as the area under the ROC curve and the coordinate axis) of the pruned model are maintained. Figure 5 As shown, with the increase of the model compression ratio, the time required for model inference gradually decreases, and the efficiency of electricity theft detection is greatly improved.
[0085] This method and apparatus for detecting electricity theft based on decentralized federated learning and pruning constructs a decentralized federated learning framework. The electricity consumption data from each power station within this framework is used to train the electricity theft detection model sequentially, eliminating the need for a central server. This improves reliability and security, addressing the issues of unreliability, interruptions, and user privacy leaks associated with central servers in existing technologies. Furthermore, this method and apparatus improves model training efficiency by performing channel pruning on the electricity theft detection model, thereby enhancing the overall performance and computational efficiency of the model.
[0086] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0087] The embodiments described above are merely specific and detailed examples of the embodiments described in this application, and should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the scope of protection of this application. Therefore, the scope of protection of this patent application should be determined by the appended claims.
Claims
1. A method for detecting electricity theft based on decentralized federated learning and pruning, characterized in that: The electricity theft detection method based on decentralized federated learning and pruning includes: The acquired electricity consumption data is input into the trained electricity theft detection model, and the output shows whether the electricity consumption data indicates electricity theft. The electricity theft detection model includes a first convolutional layer, a first activation function, a second convolutional layer, a second activation function, a third convolutional layer, a third activation function, a fourth convolutional layer, a fourth activation function, a first fully connected layer, a fifth activation function, and a second fully connected layer, which are connected sequentially from data input to output. The training process of the electricity theft detection model includes: Construct a decentralized federated learning framework, wherein the decentralized federated learning framework includes K power stations; The electricity consumption data of K power supply stations are used to train the electricity theft detection model in turn. Each training cycle of the electricity consumption data of K power supply stations is considered as one training cycle, and the training cycle is iterated. For the first training round, the parameters of the electricity theft detection model are initialized first, and the parameters of the electricity theft detection model trained at the current power station are used as the initial parameters of the electricity theft detection model trained at the next power station. For the remaining training rounds, the parameters of the electricity theft detection model completed in the previous training round are used as the initial parameters of the electricity theft detection model trained in the current round. In this round, the compression ratio of the electricity theft detection model trained at the current power station is calculated and it is determined whether the preset compression ratio has been reached. If the preset compression ratio has not been reached, the channel of the electricity theft detection model trained at the current power station is pruned according to the preset rules. Then, the parameters of the electricity theft detection model after channel pruning are used as the initial parameters of the electricity theft detection model trained at the next power station. If the preset compression ratio has been reached, the parameters of the electricity theft detection model trained at the current power station are directly used as the initial parameters of the electricity theft detection model trained at the next power station. The training continues until the preset number of training rounds is reached, resulting in a well-trained electricity theft detection model.
2. The electricity theft detection method based on decentralized federated learning and pruning as described in claim 1, characterized in that: During the training of the electricity theft detection model at each power supply station, the update formula for the parameters of the electricity theft detection model is as follows: in, in, This represents the parameters of the electricity theft detection model trained at the k-th power station in the t-th round. Let represent the initial parameters of the electricity theft detection model trained at the k-th power station in the t-th round, and η represent the learning rate. Represents the classification cross-entropy loss function Regarding parameters The gradient, := indicates overwriting the previous value. This indicates that the parameters of the electricity theft detection model are initialized in the first training round. This represents the parameters of the electricity theft detection model trained at the (k-1)th power station in the t-th round. Let represent the parameters of the electricity theft detection model trained for the Kth power station in the (t-1)th round, where t represents the training round, T represents the total number of training rounds, and T >
1. This represents the parameters obtained after channel pruning for the electricity theft detection model trained at the (k-1)th power station in the t-th round.
3. The electricity theft detection method based on decentralized federated learning and pruning as described in claim 1, characterized in that: The compression ratio of the electricity theft detection model trained at the current power station is calculated using the following formula: Where r represents the compression ratio of the currently trained electricity theft detection model. This represents the parameters of the electricity theft detection model trained for the k-th power station in the t-th round. This represents the computational complexity of the electricity theft detection model trained for the k-th power station in the t-th round. This represents the parameters of the electricity theft detection model initialized in the first training round. This represents the computational cost of the electricity theft detection model initialized in the first training round.
4. The electricity theft detection method based on decentralized federated learning and pruning as described in claim 1, characterized in that: The process of pruning the channels of the electricity theft detection model trained at the current power station according to preset rules includes: First, calculate the importance score of each channel in each layer of the trained electricity theft detection model for the current power station, using the following formula: Where Importance(i) represents the importance score of channel i, N i w represents the number of weights for channel i. ij This represents the j-th weight in channel i; Then, within each layer of the structure, all channels are sorted from highest to lowest importance score, and the last M channels in the sorted channels are ranked according to a preset ratio. l Each channel is pruned, and the calculation formula is as follows: M l =P×C l ×100% Among them, M l This indicates that after sorting the channels in the l-th layer structure according to their importance scores from high to low, the final M-order sequence is... l Each channel is pruned, where P represents the preset ratio during the channel pruning process, and C... l This indicates the number of channels in the l-th layer structure.
5. The electricity theft detection method based on decentralized federated learning and pruning as described in claim 1, characterized in that: Each activation function uses the ReLU activation function.
6. A device for detecting electricity theft based on decentralized federated learning and model pruning, characterized in that: Electricity theft detection devices based on decentralized federated learning and model pruning include: A smart meter equipped with a trained electricity theft detection model is used to collect electricity consumption data and to detect whether the electricity consumption data contains electricity theft behavior. The electricity theft detection model includes a first convolutional layer, a first activation function, a second convolutional layer, a second activation function, a third convolutional layer, a third activation function, a fourth convolutional layer, a fourth activation function, a first fully connected layer, a fifth activation function, and a second fully connected layer, which are connected in sequence from data input to output. The first module is used to construct a decentralized federated learning framework, wherein the decentralized federated learning framework includes K power stations, the electricity consumption data of the K power stations are obtained through K clients respectively, and the first module is also used to train the electricity theft detection model in turn with the electricity consumption data of the K power stations obtained by the K clients in turn, and to iterate the model by taking each turn of training with the electricity consumption data of the K power stations as a training round. In the first training round, the first module is also used to initialize the parameters of the trained electricity theft detection model and to use the parameters of the trained electricity theft detection model of the current power station as the initial parameters of the trained electricity theft detection model of the next power station. In the remaining training rounds, the first module is also used to use the parameters of the electricity theft detection model completed in the previous training round as the initial parameters of the electricity theft detection model trained in the current round. In the current round, it is used to calculate the compression ratio of the electricity theft detection model trained at the current power station and determine whether it has reached the preset compression ratio. If it has not reached the preset compression ratio, it is used to perform channel pruning on the electricity theft detection model trained at the current power station according to preset rules. Then, it is used to use the parameters of the electricity theft detection model after channel pruning as the initial parameters of the electricity theft detection model trained at the next power station. If it has reached the preset compression ratio, it is used to directly use the parameters of the electricity theft detection model trained at the current power station as the initial parameters of the electricity theft detection model trained at the next power station. The first module is also used to preset the number of training rounds and to stop training the electricity theft detection model after the number of training rounds has been reached.