Api information processing, lstm model training method and device, equipment and medium
By using an LSTM model trained based on the particle swarm optimization algorithm, the API monitoring configuration is automatically adjusted, solving the problem of poor real-time performance of API information management caused by manual maintenance in existing technologies, and realizing efficient and automated management of API information.
Patent Information
- Application Number
- CN202210002267.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-04
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2042-01-04
AI Technical Summary
Existing API information management methods require manual maintenance, cannot reflect API changes in real time, resulting in high manpower costs and poor real-time performance.
A Long Short-Term Memory (LSTM) network model trained based on the particle swarm optimization algorithm is adopted. By acquiring API information and performing frequency prediction, the monitoring configuration is automatically adjusted to achieve real-time management of API information.
It has achieved automated management of API information, reduced manual intervention, improved the real-time performance and efficiency of monitoring, rationally allocated resources, and ensured stable service operation.
Smart Images

Figure CN116450445B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information technology, and in particular to an application programming interface (API) information processing method, a long short-term memory (LSTM) model training method and apparatus, electronic devices and storage media. Background Technology
[0002] In existing technologies, API information is typically managed using the following methods:
[0003] Method 1: Manage documents through file-based methods such as Markdown, Excel, or Word documents;
[0004] Method 2: Manage via open-source API management tools such as YAPIi;
[0005] Method 3: Develop your own unified API management platform, which allows users to import API documentation themselves or periodically retrieve user API information for management.
[0006] While existing technologies can manage API information, they have the following drawbacks:
[0007] Methods 1 and 2 both require manual maintenance, and changes to the API cannot be reflected to the caller in real time. Therefore, they require a lot of manpower and have poor real-time performance. Method 3 also requires manual maintenance and manual import, which also requires a lot of manpower. Summary of the Invention
[0008] This application provides an API information processing method, an LSTM model training method and apparatus, an electronic device, and a storage medium to solve the problem of difficulty in acquiring and managing API information.
[0009] A first aspect of this disclosure provides a method for processing application programming interface (API) information, the method comprising:
[0010] Obtain API information collected within the nth time period using the nth monitoring configuration; where n is a positive integer;
[0011] The API information is input into a Long Short-Term Memory (LSTM) network model trained based on the particle swarm optimization algorithm to obtain the nth predicted value of the API change frequency.
[0012] Based on the nth predicted value, the (n+1)th monitoring configuration is determined, wherein the (n+1)th monitoring configuration is used for collecting API information during the (n+1)th time period.
[0013] Based on the above scheme, the training of the Long Short Memory (LSTM) network model trained using the particle swarm optimization algorithm includes:
[0014] The learning rate of the s-th particle in the particle swarm is determined based on the particle swarm algorithm. Using the API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as the label, an LSTM model containing m hidden layer nodes is trained in the x-th round to obtain the x-th prediction value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S, where S is the total number of particles in the particle swarm.
[0015] The x-th error is determined based on the difference between the x-th predicted value and the label;
[0016] If the x-th error does not meet the preset condition, update m or lr in the s-th particle and perform iterative update training based on the s-th particle;
[0017] The group error of the particle swarm is determined based on the error of S particles in the particle swarm satisfying the preset conditions, wherein the group error is the minimum error in the particle swarm that satisfies the preset conditions.
[0018] Based on the particles corresponding to the group error, the number of hidden layer nodes and model parameters of the LSTM model are determined.
[0019] Based on the above scheme, the LSTM model includes multiple stacked LSTM layers.
[0020] Based on the above scheme, obtaining the API information collected in the nth time period with the nth monitoring configuration includes:
[0021] According to the nth monitoring configuration, listen to the relevant files of the API, wherein the relevant files include: the API's project file and / or documentation file;
[0022] When it is determined from the relevant documents that there is an API information update, the updated API information is read.
[0023] Based on the above scheme, the step of reading the API information when it is determined from the relevant documents that the API information has been updated includes:
[0024] When it is determined from the relevant files that API information has been updated during the nth time period, read the API information;
[0025] The update type of the API information is determined by comparing the API information read in the nth time period with the API information collected in the (n-1)th time period.
[0026] Specifically, when the API information is fully updated, all API information read will be the API information input to the LSTM model;
[0027] When the API information is an incremental update, the incrementally updated API information is the API information input into the LSTM model.
[0028] Based on the above scheme, the step of determining the update type of the API information by comparing the API information read in the nth time period with the API information collected in the (n-1)th time period includes:
[0029] Obtain the nth summary information of the API information collected in the nth time period;
[0030] The nth summary information is compared with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period.
[0031] Based on the above scheme, comparing the nth summary information with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period includes:
[0032] When the nth predicted value increases relative to the (n-1)th predicted value corresponding to the nth monitoring configuration, the monitoring frequency included in the nth monitoring configuration is increased to obtain the monitoring frequency included in the (n+1)th monitoring configuration.
[0033] or,
[0034] When the frequency of change of the nth predicted value relative to the API information of the nth time period decreases, the monitoring frequency included in the nth monitoring configuration is reduced to obtain the monitoring frequency included in the (n+1)th monitoring configuration.
[0035] A second aspect of this disclosure provides an API information processing apparatus, the apparatus comprising:
[0036] The acquisition module is used to acquire API information collected with the nth monitoring configuration within the nth time period; where n is a positive integer;
[0037] The prediction module is used to input the API information into the Long Short Memory Network (LSTM) model trained based on the particle swarm optimization algorithm to obtain the nth predicted value of the API change frequency.
[0038] The determination module is used to determine the (n+1)th monitoring configuration based on the nth predicted value, wherein the (n+1)th monitoring configuration is used for collecting API information during the (n+1)th time period.
[0039] Based on the above scheme, the device includes:
[0040] The training module is used to determine the learning rate of the s-th particle in the particle swarm based on the particle swarm algorithm. It uses API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as the label. The x-th prediction value is obtained by training an LSTM model containing m hidden layer nodes for the x-th round. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, and the learning rate lr. The s is less than or equal to S, where S is the total number of particles in the particle swarm.
[0041] A particle error determination module is used to determine the x-th error based on the difference between the x-th predicted value and the label;
[0042] The update module is used to update m or lr in the s-th particle when the x-th error does not meet the preset condition, and to perform iterative update training based on the s-th particle;
[0043] The group error module is used to determine the group error of the particle swarm based on the errors of S particles in the particle swarm that satisfy a preset condition, wherein the group error is the minimum error in the particle swarm that satisfies the preset condition.
[0044] The model determination module is used to determine the number of hidden layer nodes and model parameters of the LSTM model based on the particles corresponding to the group error.
[0045] Based on the above scheme, the LSTM model includes multiple stacked LSTM layers.
[0046] Based on the above scheme, the acquisition module includes: a monitoring unit, used to monitor the relevant files of the API according to the nth monitoring configuration, wherein the relevant files include: the API's project file and / or documentation file;
[0047] The reading unit is used to read the updated API information when it is determined from the relevant file that the API information has been updated.
[0048] Based on the above scheme, the reading unit is specifically used to read API information when it is determined from the relevant file that API information has been updated during the nth time period;
[0049] The update type of the API information is determined by comparing the API information read in the nth time period with the API information collected in the (n-1)th time period.
[0050] When the API information is fully updated, all the API information read will be the API information input into the LSTM model;
[0051] When the API information is an incremental update, the incrementally updated API information is the API information input into the LSTM model.
[0052] Based on the above scheme, the reading unit is specifically used to obtain the nth summary information of the API information collected in the nth time period; compare the nth summary information with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period.
[0053] Based on the above scheme, the determining module is specifically used to increase the monitoring frequency included in the nth monitoring configuration to obtain the monitoring frequency included in the n+1th monitoring configuration when the nth predicted value increases relative to the (n-1)th predicted value corresponding to the nth monitoring configuration; or, when the nth predicted value decreases relative to the change frequency of the API information in the nth time period, decrease the monitoring frequency included in the nth monitoring configuration to obtain the monitoring frequency included in the n+1th monitoring configuration.
[0054] A third aspect of this disclosure provides an LSTM model training method, including:
[0055] The learning rate of the s-th particle in the particle swarm is determined based on the particle swarm algorithm. Using the API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as the label, an LSTM model containing m hidden layer nodes is trained in the x-th round to obtain the x-th prediction value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S, where S is the total number of particles in the particle swarm.
[0056] The x-th error is determined based on the difference between the x-th predicted value and the label;
[0057] If the x-th error does not meet the preset condition, update m or lr in the s-th particle and perform iterative update training based on the s-th particle;
[0058] The group error of the particle swarm is determined based on the error of S particles in the particle swarm satisfying the preset conditions, wherein the group error is the minimum error in the particle swarm that satisfies the preset conditions.
[0059] Based on the particles corresponding to the group error, determine the number of hidden layer nodes and model parameters of the LSTM model;
[0060] The trained LSTM model is used to predict the change frequency of API information in the next time period based on the API information collected in the previous time period. The predicted change frequency is used to determine the monitoring configuration for the next time period.
[0061] Based on the above scheme, the LSTM model includes multiple stacked LSTM layers.
[0062] A fourth aspect of this disclosure provides an LSTM model training apparatus, comprising:
[0063] The training module is used to determine the learning rate of the s-th particle in the particle swarm based on the particle swarm algorithm. It uses API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as a label to perform the x-th round of training on an LSTM model containing m hidden layer nodes to obtain the x-th prediction value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S, where S is the total number of particles in the particle swarm.
[0064] A particle error module is used to determine the x-th error based on the difference between the x-th predicted value and the label;
[0065] The update module is used to update m or lr in the s-th particle when the x-th error does not meet the preset condition, and to perform iterative update training based on the s-th particle;
[0066] The group error module is used to determine the group error of the particle swarm based on the errors of S particles in the particle swarm that satisfy a preset condition, wherein the group error is the minimum error in the particle swarm that satisfies the preset condition.
[0067] The model determination module is used to determine the number of hidden layer nodes and model parameters of the LSTM model based on the particles corresponding to the group error.
[0068] The trained LSTM model is used to predict the change frequency of API information in the next time period based on the API information collected in the previous time period. The predicted change frequency is used to determine the monitoring configuration for the next time period.
[0069] Based on the above scheme, the LSTM model includes multiple stacked LSTM layers.
[0070] A fifth aspect of this disclosure provides an electronic device, comprising:
[0071] Memory;
[0072] A processor, connected to the memory, is configured to implement the method provided by any of the technical solutions of the first or second aspect by executing computer-executable instructions stored in the memory.
[0073] A sixth aspect of this disclosure provides a computer storage medium, characterized in that the computer storage medium stores computer-executable instructions; after the computer-executable instructions are executed by a processor, they implement the method provided by any of the technical solutions of the first or second aspect.
[0074] In this embodiment of the disclosure, the API information collected according to the nth monitoring configuration during the nth time period is input into the LSTM model trained based on the particle swarm optimization algorithm to obtain the nth predicted value of the API change frequency. This nth predicted value is used to determine the monitoring configuration during the n+1th time period. Thus, the appropriate monitoring configuration for monitoring API information is determined in this way. This method has a high degree of automation and monitors API information with appropriate monitoring configuration, reducing the phenomenon of high power consumption or insufficient monitoring caused by excessively frequent monitoring. Attached Figure Description
[0075] Figure 1 A flowchart illustrating an API information processing method provided in an embodiment of this application;
[0076] Figure 2 A schematic diagram of a neural unit provided in an embodiment of this application;
[0077] Figure 3 A schematic diagram of a two-layer LSTM model provided for an embodiment of this application;
[0078] Figure 4 A flowchart illustrating an API information processing method provided in an embodiment of this application;
[0079] Figure 5 A flowchart illustrating an LSTM model training method provided in an embodiment of this application;
[0080] Figure 6 A schematic diagram of an API information processing API plugin provided in an embodiment of this application;
[0081] Figure 7 A flowchart illustrating an API information processing method provided in an embodiment of this application;
[0082] Figure 8 This is a flowchart illustrating an LSTM model training method based on particle swarm optimization provided in an embodiment of this application.
[0083] Figure 9 This is a flowchart illustrating an API information processing method provided in an embodiment of this application;
[0084] Figure 10 This is a schematic diagram of the structure of an API information processing device provided in an embodiment of this application;
[0085] Figure 11 This is a schematic diagram of the structure of an LSTM model training device provided in an embodiment of this disclosure.
[0086] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0087] To gain a more detailed understanding of the features and technical content of this application, the implementation of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference and illustration only and are not intended to limit this application.
[0088] like Figure 1 As shown, this disclosure provides an embodiment of...
[0089] A text processing method, characterized in that the method includes:
[0090] S110: Obtain API information collected within the nth time period using the nth monitoring configuration; where n is a positive integer;
[0091] S120: Input the API information into the LSTM model trained based on the particle swarm optimization algorithm to obtain the nth predicted value of the API change frequency;
[0092] S130: Based on the nth predicted value, determine the n+1th monitoring configuration, wherein the n+1th monitoring configuration is used for collecting API information during the n+1th time period.
[0093] The API information processing method provided in this functional embodiment can be implemented using an LSTM model. This LSTM model can be a model including a single LSTM layer or a model including multiple LSTM layers.
[0094] The LSTM layer includes one or more LSTM neural units.
[0095] refer to Figure 2 As shown, one of the LSTM neural units may include:
[0096] It consists of a forget gate, an input gate, an output gate, and a memory unit.
[0097] x t h t-1 These represent the input at the current time step and the output at the previous time step, respectively. t This represents the forget gate, indicating what information from the previous moment needs to be used in the current moment.
[0098] The mathematical form of neural unit computation is shown below:
[0099] f t=s(W f *[h t-1 x t ]+b f )
[0100] W f b represents the weight of the output of the forget gate. f The threshold value for the output of the forget gate.
[0101] f t =s(W f *[h t-1 x t ]+b f )
[0102] i t The input gate also uses the sigmoid function to determine which information is needed to update the current value, as shown in the following mathematical form:
[0103] i t =s(W i *[h t-1 x t ]+b i )
[0104] W i b represents the weights of the input gate's output; i The threshold value is the output threshold of the input gate.
[0105] c_in t This represents using the tanh function to generate new candidate values, mathematically as shown below:
[0106] c_in t =tanh(W i *[h t-1 x t ])
[0107] will i t Same as c_in t Combined, these form the current memory cell state Ct, as shown in the following functional relationship:
[0108] C t =f t *C t-1 +i t *c_in t
[0109] O t The output gate uses a sigmoid layer, as shown in the function relationship below:
[0110] O t =σ(W O *[ht-1 x t ]+b O )
[0111] h t ht represents the output of the network unit at the current time. The tanh function is used to normalize Ct, and then compared with O. t The results are obtained by multiplying the groups, as shown in the following functional relationship:
[0112] h t =O t *tanh(C t )
[0113] Figure 3 A schematic diagram of a two-layer LSTM model, which may include a single-layer LSTM and a two-layer LSTM.
[0114] This LSTM model is trained using the particle swarm optimization algorithm and has relatively accurate predictive capabilities. Therefore, the predicted value of the frequency of change at the output of this LSTM model is relatively accurate, and the monitoring configuration based on this prediction value is more in line with monitoring requirements.
[0115] For example, the nth predicted value is positively correlated with the monitoring frequency included in the (n+1)th monitoring configuration.
[0116] The API information includes, but is not limited to:
[0117] The name of the API;
[0118] The number of parameters in the API;
[0119] The API includes the following parameters;
[0120] API parameter names;
[0121] API parameter types;
[0122] The address of the API management center;
[0123] API version.
[0124] The API information input into the LSTM model includes, but is not limited to, at least one of the following:
[0125] The changed API information;
[0126] The difference in API information before and after the change;
[0127] API change information.
[0128] For example, the API change information includes, but is not limited to, at least one of the following:
[0129] The number of times API information has changed, the number of API changes, the number of API parameter changes, the name of the API after the change, and the name of the API parameter after the change, etc.
[0130] In summary, after this API information is input into the LSTM model, the LSTM model can give the nth predicted value of the API transformation frequency in the nth time period based on the API information.
[0131] The (n+1)th monitoring configuration may include at least one of the following:
[0132] The (n+1)th monitoring frequency;
[0133] The (n+1)th monitoring cycle.
[0134] Optionally, the (n+1)th monitoring frequency is positively correlated with the nth predicted value; the (n+1)th monitoring frequency is negatively correlated with the (n+1)th monitoring period.
[0135] For example, the (n+1)th monitoring frequency and the nth predicted value have a preset functional relationship, which can be a direct proportional function or the like.
[0136] Of course, the above are just examples, and the specific implementation is not limited to these.
[0137] In some embodiments, the durations of the nth time period and the (n+1)th time period may be equal or unequal. For example, if monitoring is performed according to a preset period, the nth and (n+1)th time periods may be two preset periods that are adjacent in the time domain. As another example, if the nth monitoring period includes the duration information of the nth time period, the duration information of the (n+1)th time period may be indicated by the nth monitoring configuration. In this case, the nth and (n+1)th time periods are two time periods that are adjacent in time domain, but their durations may be unequal.
[0138] In some embodiments, such as Figure 4 As shown, the training of the Long Short-Term Memory (LSTM) network model obtained based on the particle swarm optimization algorithm includes:
[0139] S101: Based on the particle swarm optimization algorithm, determine the learning rate of the s-th particle in the particle swarm. Using the API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as the label, train the LSTM model containing m hidden layer nodes for the x-th round to obtain the x-th prediction value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S. S is the total number of particles in the particle swarm; x is any positive integer.
[0140] S102: Determine the x-th error based on the difference between the x-th predicted value and the label;
[0141] S103: If the x-th error does not meet the preset condition, update m or lr in the s-th particle and perform iterative update training based on the s-th particle;
[0142] S104: Determine the group error of the particle swarm based on the error of S particles in the particle swarm satisfying the preset conditions, wherein the group error is the minimum error in the particle swarm that satisfies the preset conditions.
[0143] S105: Determine the number of hidden layer nodes and model parameters of the LSTM model based on the particles corresponding to the group error.
[0144] A particle in the particle swarm optimization algorithm can contain three particle features, which correspond to the particle's position, velocity, and fitness value.
[0145] In this embodiment of the disclosure, the particle swarm may contain S particles, which may be determined during model training initialization, for example, random values determined by a random algorithm, or configuration values received from a peripheral device. In some embodiments, the number of S may be 50, 100, 200, or 1000, etc.
[0146] The initial values of the particle characteristics of these S particles can also be determined during initialization, for example, based on a random algorithm or based on preset configuration data. If determined based on preset configuration data, then the m value will be different for different particles, and / or the lr value will be different for different particles.
[0147] In this embodiment of the disclosure, when training an LSTM model based on the particle swarm optimization algorithm, the three particle features of a particle correspond to the number of hidden layer nodes, the learning rate, and the error after training of the LSTM model, respectively.
[0148] For example, the number of hidden layer nodes can be used as the position in the particle features, the learning rate can be used as the velocity in the particle features, and the error can be used as the fitness value in the particle features. Alternatively, the number of hidden layer nodes can be used as the velocity in the particle features, the learning rate can be used as the position in the particle features, and the error can be used as the fitness value in the particle features.
[0149] An LSTM module consists of an input layer, a hidden layer, and an output layer; the nodes contained in the hidden layer are called hidden layer nodes.
[0150] The greater the difference between the x-th predicted value and the label, the greater the x-th error; the smaller the difference between the x-th predicted value and the label, the smaller the x-th error.
[0151] In this embodiment of the disclosure, the x-th error not satisfying the preset condition may include at least one of the following:
[0152] The x-th error does not converge or remains stable;
[0153] The xth error is not less than the preset error value.
[0154] If the x-th error corresponding to the x-th particle does not meet the preset conditions, it is equivalent to not finding the optimal fitness value of the x-th particle. Therefore, the number of hidden layer nodes and / or learning rate corresponding to the s-th particle will be updated, and the LSTM model will be retrained based on the updated particle features of the x-th particle until the particle features of the x-th particle corresponding to the x-th error that meets the preset conditions are found.
[0155] The final parameters of the LSTM model are determined based on the minimum error among all particles in the entire particle swarm. This ensures that the trained LSTM model has a relatively accurate predictive ability.
[0156] The xth training iteration here can be performed using one or more batches of sample data. Each batch of sample data must include at least one sample data.
[0157] For example, if the group error can be the error of the Oth particle, then the LSTM model determined by the m of the Oth particle is used, and the LSTM model trained using the learning rate of the Oth particle is used as the final trained model.
[0158] In this embodiment of the disclosure, the x-th error can also be understood as the x-th loss value, which is a loss value calculated based on the difference between the x-th predicted value labels. This loss value can be calculated using various loss functions.
[0159] In one embodiment, the LSTM model comprises multiple stacked LSTM layers.
[0160] The network structure of multiple LSTM layers can be the same, but after training, the model parameters of different LSTM layers can be different. These model parameters include, but are not limited to, node weights and / or thresholds.
[0161] In some embodiments, S110 may include:
[0162] According to the nth monitoring configuration, listen to the relevant files of the API, wherein the relevant files include: the API's project file and / or documentation file;
[0163] When it is determined from the relevant documents that there is an API information update, the updated API information is read.
[0164] According to the nth monitoring configuration, it will listen to relevant files of the API within the API platform. For example, if a new project is added, there will be corresponding project files. These project files may include: files describing the project content, creation files, and / or resource files used by the resources. Of course, the above is just an example; in actual implementation, the project files include, but are not limited to, these.
[0165] If an API within a project is updated, there will be corresponding documentation files, which may include, but are not limited to, source code files and / or object code files.
[0166] After obtaining these API-related documents, we will determine whether there are any updates to the API information based on these documents. If there are updated API information, we will read the API information from these documents or from the API platform.
[0167] Furthermore, when it is determined from the relevant documents that API information has been updated, reading the API information includes:
[0168] When it is determined from the relevant files that API information has been updated during the nth time period, read the API information;
[0169] The update type of the API information is determined by comparing the API information read in the nth time period with the API information collected in the (n-1)th time period.
[0170] Specifically, when the API information is fully updated, all API information read will be the API information input to the LSTM model;
[0171] When the API information is an incremental update, the incrementally updated API information is the API information input into the LSTM model.
[0172] In this embodiment of the disclosure, if the API information is updated in full, all the read API information is fed into the LSTM model. If it is updated incrementally, only the incremental update part is input into the LSTM model. The LSTM model gives a predicted value of the change frequency of the API information in the next time period based on the input API information.
[0173] For example, determining the update type of the API information by comparing the API information read in the nth time period with the API information collected in the (n-1)th time period includes:
[0174] Obtain the nth summary information of the API information collected in the nth time period;
[0175] The nth summary information is compared with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period.
[0176] In this embodiment, the nth digest information of the API information collected in the nth time period includes, but is not limited to, MD5 information. By comparing the digest information, the update type of the API information collected in the nth time period can be determined, for example, whether it is a full update or an incremental update.
[0177] The step of comparing the nth summary information with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period includes:
[0178] When the frequency of change of the nth predicted value relative to the API information of the nth time period increases, the monitoring frequency included in the nth monitoring configuration is increased to obtain the monitoring frequency included in the (n+1)th monitoring configuration.
[0179] or,
[0180] When the frequency of change of the nth predicted value relative to the API information of the nth time period decreases, the monitoring frequency included in the nth monitoring configuration is reduced to obtain the monitoring frequency included in the (n+1)th monitoring configuration.
[0181] In this embodiment of the disclosure, the nth monitoring configuration includes at least a monitoring frequency. The change of the monitoring frequency in the (n+1)th monitoring configuration relative to the monitoring frequency in the nth monitoring configuration can be determined by the relationship between the nth predicted value and the actual change frequency of the API information in the nth time period, thereby obtaining a suitable monitoring frequency for the (n+1)th time period.
[0182] In some embodiments, the relationship between the actual frequency of change of the API information in the nth time period and the nth predicted value in the nth time period is determined.
[0183] When the difference between the actual change frequency of the API information and the nth predicted value is within a preset range, the monitoring frequency included in the nth monitoring configuration is obtained by increasing or decreasing the monitoring frequency included in the nth monitoring configuration based on the relationship between the nth predicted value and the change frequency of the API information in the nth time period (i.e., the actual change frequency).
[0184] If the difference between the actual change frequency of the API information and the nth predicted value is not within a preset range, then based on the relationship between the nth predicted value and the change frequency of the API information in the nth time period (i.e., the actual change frequency), the monitoring frequency included in the nth monitoring configuration is obtained by increasing or decreasing the actual change frequency of the API information in the nth time period.
[0185] Using this method, a monitoring frequency more suitable for the (n+1)th time period is obtained based on the relatively accurate prediction value output by the LSTM.
[0186] like Figure 5 As shown, this disclosure provides an LSTM model training method, including:
[0187] S210: Based on the particle swarm optimization algorithm, determine the learning rate of the s-th particle in the particle swarm. Using the API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as the label, train the LSTM model containing m hidden layer nodes for the x-th round to obtain the x-th prediction value; wherein, the particle features of the s-th particle include: the number of hidden layer nodes m of the LSTM model, the learning rate lr, and s is less than or equal to S; where S is the total number of particles in the particle swarm.
[0188] S220: Determine the x-th error based on the difference between the x-th predicted value and the label;
[0189] S230: If the x-th error does not meet the preset condition, update m or lr in the s-th particle and perform iterative update training based on the s-th particle;
[0190] S240: Determine the group error of the particle swarm based on the error of S particles in the particle swarm satisfying the preset conditions, wherein the group error is the minimum error in the particle swarm that satisfies the preset conditions.
[0191] S250: Determine the number of hidden layer nodes and model parameters of the LSTM model based on the particles corresponding to the group error;
[0192] The trained LSTM model is used to predict the change frequency of API information in the next time period based on the API information collected in the previous time period. The predicted change frequency is used to determine the monitoring configuration for the next time period.
[0193] Using the particle swarm optimization algorithm to build an LSTM model can produce a predictive model that can accurately output the frequency of changes in API information in the next time period.
[0194] For example, the xth training round can be: the xth round of batch training on a large amount of data. In short, a training round includes training on at least one sample data.
[0195] In some embodiments, the LSTM model includes multiple stacked LSTM layers.
[0196] The x-th error can be the arithmetic mean of the errors corresponding to each sample data in the x-th training round.
[0197] To calculate the error of a single sample data, various loss functions of deep learning models can be used, such as the cross-entropy function.
[0198] During the training of the model, if the error cannot meet the preset conditions, the minimum error will be selected as the optimal fitness of the particle when the number of iterations for the corresponding particle reaches the maximum number of iterations.
[0199] Regularly and proactively retrieve the latest API information for the product. If the data retrieval interval is too short, there is a high probability of invalid retrieval (i.e., the user's API information has not changed); if the data retrieval interval is too long, it will have a certain impact on the product's performance.
[0200] This disclosure provides an API collection plugin that requires no manual intervention. The API plugin is configurable and pluggable. For example, when a project is unlinked from a document, the API collection plugin adaptively senses changes in API information based on user habits, collects API change data, and effectively pushes API information.
[0201] In enterprise-level development, especially in large technology companies, the number of APIs is substantial and they change more frequently. How can we better and more efficiently monitor API changes? This paper proposes using an optimized multi-layer LSTM model to predict API changes.
[0202] If it is possible to predict that API changes will be extremely frequent in the future, reasonable monitoring configurations can be made in advance to increase the listening frequency. If changes to the API are predicted in the future, it can greatly ensure the reasonable allocation of resources and the stable operation of services.
[0203] This disclosure provides an API collection plugin based on an optimized multi-layer LSTM model, which automatically detects changes in API information without manual intervention; the plugin is decoupled from the document, making the API plugin configurable, pluggable, and highly flexible; and API changes are pushed in real time to ensure efficient information synchronization.
[0204] This multi-layer LSTM model may include multiple stacked LSTM layers.
[0205] This embodiment proposes a method or apparatus for real-time API information acquisition, referencing... Figure 7 As shown, this may specifically include: first, collecting historical API modification data from the project or API documentation files, and then building an API acquisition and prediction model based on a multi-layer LSTM model;
[0206] Then configure the project or document file to listen for API collectors;
[0207] The API collector implements adaptive listening based on the prediction model, shortening the API listening interval during periods when API changes are frequently predicted.
[0208] During periods when API changes are infrequent, extend the API monitoring interval to obtain real-time updates on API information.
[0209] Based on changes to the API information, the API collector directly pushes all or all changes to the API to the API management platform. The API management platform is responsible for automatically updating the API information and enabling the API to be made available to the public.
[0210] like Figure 6 As shown, this disclosure provides an API plugin, which may include:
[0211] API acquisition prediction model, which may include the aforementioned LSTM model;
[0212] The API listening module is used to listen to relevant files of the API according to the current listening configuration.
[0213] The API acquisition module is used to collect API information when the API listening module detects an API information update.
[0214] The API data preprocessing module is used to convert the format of the collected API information to obtain the converted API information. The format of this API information can be: an object structure or key-value pairs.
[0215] The API information transmission module is used to uniformly encode and compress the collected API information before transmitting it to the unified API management platform. This API data transmission module supports multi-protocol transmission, asynchronous transmission, breakpoint transmission, and offline transmission.
[0216] Figure 6 This demonstrates the relationship between the various modules of the API collector (i.e., API plugin) and the collection process. Below is a brief overview of the function of each module, following the process:
[0217] Build an API acquisition prediction model, which includes, but is not limited to, the LSTM model.
[0218] First, retrieve historical modification data records of the API from the database, and construct an ordered time series of the number of times different APIs are called in each hour, using a 10-minute unit (10 minutes is just an example, and the actual time can be any preset duration).
[0219] The actual number of API modifications was divided into orders of magnitude, with a step size of 10 modifications. Every 10 modifications were associated with an integer, resulting in a dictionary of integers such as 1:[1-10], 2:[11-20], 3:[21-30], 4:[31-40], and so on. Each positive integer can serve as an index to identify the number of API changes per unit time. The amount of change in the next unit time is predicted based on the amount of changes made every 10 unit hours. 70% of the data was used as the training dataset, and 30% as the test dataset.
[0220] When dealing with time series prediction problems, recurrent neural networks are often chosen, among which LSTM has stronger adaptability and stability because it introduces a "memory function" module.
[0221] This embodiment utilizes an optimized LSTM algorithm to build an API acquisition and prediction model to predict the frequency of API changes in the next unit of time. The LSTM neural unit includes a forget gate, an input gate, an output gate, and a memory unit.
[0222] One of the LSTM neural units may include:
[0223] It consists of a forget gate, an input gate, an output gate, and a memory unit.
[0224] x t h t-1 These represent the input at the current time step and the output at the previous time step, respectively. t This represents the forget gate, indicating what information from the previous moment needs to be used in the current moment.
[0225] The mathematical form of neural unit computation is shown below:
[0226] f t =s(W f *[h t-1 x t ]+b f )
[0227] W f b represents the weight of the output of the forget gate. f The threshold value for the output of the forget gate.
[0228] f t =s(W f *[h t-1 xt ]+b f )
[0229] i t The input gate also uses the sigmoid function to determine which information is needed to update the current value, as shown in the following mathematical form:
[0230] i t =s(W i *[h t-1 x t ]+b i )
[0231] W i b represents the weights of the input gate's output; i The threshold value is the output threshold of the input gate.
[0232] c_in t This represents using the tanh function to generate new candidate values, mathematically as shown below:
[0233] c_in t =tanh(W i *[h t-1 x t ])
[0234] will i t Same as c_in t Combined, these form the current memory cell state Ct, as shown in the following functional relationship:
[0235] C t =f t *C t-1 +i t *c_in t
[0236] O t The output gate uses a sigmoid layer, as shown in the function relationship below:
[0237] O t =σ(W O *[h t-1 x t ]+b O )
[0238] h t ht represents the output of the network unit at the current time. The tanh function is used to normalize Ct, and then compared with O. t The results are obtained by multiplying the groups, as shown in the following functional relationship:
[0239] h t =O t *tanh(Ct )
[0240] A high-performance LSTM model is key to obtaining good prediction results. The key to building an LSTM neural network lies in the number of hidden layer nodes m and the learning rate lr.
[0241] Optimizing the key parameters m (number of hidden layer nodes) and l (learning rate) in a multilayer LSTM model using the particle swarm optimization algorithm. r A swarm of particles is initialized in the solvable space, with each particle representing an optimal solution. The particle's characteristics are represented by three metrics: position, velocity, and fitness value. Particles update themselves using their individual best value (Pbest) and swarm best value (Gbest, the aforementioned swarm error). Pbest represents the position with the best calculated fitness value among the positions the particle has experienced, and Gbest represents the optimal fitness value found by all particles in the swarm. Each time a particle updates its position, it calculates its fitness value and updates both Pbest and Gbest by comparing the new particle's fitness value, the individual best value, and the swarm best value.
[0242] Set the range of hidden nodes in the LSTM model to m∈[1,20], l r The range is l r ∈[0.001,0.01], initialize particle swarm parameters, set population size, number of iterations, inertia weight and acceleration factor.
[0243] Select initial m and l r Build an LSTM model, compare the results with the test results, and use the relative error between the true values and predicted values of the training samples as the fitness value. Where P is the number of training samples, y p For the true value, y' p These are predicted values.
[0244] The fitness value of the particles will tend to stabilize with iteration, satisfying the termination condition, and the optimal parameter values m of the LSTM model will be obtained. optimal and l optimal .
[0245] Optimizing the key parameters m (number of hidden layer nodes) and l (learning rate) in a multilayer LSTM model using the particle swarm optimization algorithm. r The process is as follows Figure 8 As shown, it may include:
[0246] Initialize particle swarm parameters: population size, maximum number of iterations, inertia weight, acceleration factor, and fitness value;
[0247] The relative error between the true and predicted values of the training samples is used as the fitness value of the particle swarm.
[0248] Initialize particles (update particles), supervise the LSTM model, and calculate the fitness value of each particle;
[0249] If the current fitness value of each particle is less than that of the previous iteration, then update the individual value Pbest.
[0250] If the current globally optimal fitness value is affected by the previous fall, update the population extreme value Gbest;
[0251] Based on the individual optimal value of fitness and the global minimum value, adjust and update the particle velocity and particle position;
[0252] Determine if the fitness value has stabilized or reached the maximum number of iterations;
[0253] Obtain the optimal number of hidden layer nodes and learning rate.
[0254] Build with m optimal A two-layer LSTM neural network model with hidden nodes is used to predict API data modifications. The optimized dual LSTM prediction model architecture is shown in the figure below. Figure 3 As shown.
[0255] One layer of LSTM has m optimal There are m hidden nodes, representing consecutive m nodes. optimal Given a unit time series, input an integer vector of size 1×m. optimal , representing m whose value range is [1-100]. optimal A positive integer.
[0256] In a single LSTM layer, the weight dimension w is taken. i The value is 32. After the convolution operation, the output vector of the first layer of the network becomes 32×m. optimal Dimension. The number of hidden nodes in a two-layer LSTM is also m. optimal Similarly, by controlling the output weights of the second-layer LSTM, the output vector is reclassified to 1×m. optimal That is, re-output m optimal The predicted value for the final time step is obtained by taking the output value of the last time node of the second result layer from a set of distinct positive integers. The optimized two-layer LSTM prediction model allows for greater model complexity, enabling the acquisition of deeper data features and achieving better prediction results.
[0257] Regarding the API monitoring module: The monitoring sources are mainly projects (supporting Java, Python, and Golang) and files (MD files that meet certain API formats, and Swagger files). Based on the results of the API change prediction model, the monitoring frequency is adaptively adjusted, and changes in the MD5 values of files or API information are detected in real time. Once a change occurs, the API acquisition module is immediately notified.
[0258] Regarding the API acquisition module:
[0259] Upon receiving a data collection notification, the data collection module will read project or API information. If the type being monitored is a project, it will scan the code under the corresponding package and retrieve all interface information. If it's a Material Design (MD) file, it will read and parse the API information using PEGdown. If it's a Swagger file, it will obtain the API information using JSON.
[0260] Regarding the API data preprocessing module: +
[0261] Upon receiving API information, it is uniformly converted into an object structure or key-value pairs. By comparing it with historical versions, it is determined whether the API information is a full update or an incremental update. If it is an incremental update, the incrementally updated portion is selected and passed to the data transmission module. This improves efficiency, especially when the API information data volume is large and updates are frequent.
[0262] Regarding the API data transfer module:
[0263] The transmission module receives the data and performs unified encoding and compression, supporting multiple protocols (HTTP / HTTPS, TCP), asynchronous transmission, breakpoint transmission, and offline transmission to send it to the API unified management platform.
[0264] The following is a configuration example of an API collector:
[0265] service.type = project
[0266] service.name = APIg
[0267] service.version = 1.0.1
[0268] service.metaUrl=http: / / 172.16.78.155:8080 / API / add
[0269] scan.basePackage=com.APIg.API
[0270] scan.description = APIg
[0271] scan. Author: wangyongjian
[0272] scan.selfhostEnable = true
[0273] The parameters have the following meanings:
[0274]
[0275] refer to Figure 9 As shown, this disclosure provides a method that may include:
[0276] Configure listeners for the project, for example, Figure 9 As shown, configure a listener for project A;
[0277] The API monitoring module detects changes in the MD5 value of files to perceive API information in real time.
[0278] When the MD5 value of the API information changes, the API collection module is notified to collect the data.
[0279] Upon receiving the notification, the API acquisition module immediately reads the API information and passes it to the API data preprocessing module.
[0280] The API data processing module compares API information with historical versions to determine whether it is an update or a full addition.
[0281] If it is a full addition, the collected API data will be transmitted to the API transmission module.
[0282] The API transmission module transmits data to the API management platform via network transmission.
[0283] The API management platform provides a unified display and accessibility.
[0284] If it is an update, the API difference data is filtered and provided to the API data transmission module for use by the API management platform. In summary, in this embodiment, the updated API information is provided to the API management platform through comparison.
[0285] In summary, this disclosure provides a plugin for automatic API collection that is non-intrusive to the project itself and supports the collection of multiple file types.
[0286] By monitoring files, we can detect dynamic changes in the API in real time and update the API efficiently.
[0287] The data preprocessing module can better identify whether an API is newly added or updated. If it is an update, it can push a small amount of data, greatly improving transmission performance.
[0288] The entire process is fully automated and requires no human intervention.
[0289] like Figure 10As shown, this disclosure provides an API information processing apparatus, the apparatus comprising:
[0290] The acquisition module 110 is used to acquire API information collected with the nth monitoring configuration within the nth time period; wherein, n is a positive integer;
[0291] Prediction module 120 is used to input the API information into a Long Short-Term Memory (LSTM) network model trained based on particle swarm optimization algorithm to obtain the nth predicted value of the API change frequency.
[0292] The determination module 130 is used to determine the (n+1)th monitoring configuration based on the nth predicted value, wherein the (n+1)th monitoring configuration is used for collecting API information during the (n+1)th time period.
[0293] In some embodiments, the acquisition module 110, the prediction module 120, and the determination module 130 may be program modules; after the program module is executed by the processor, it can implement the operations of the above-mentioned modules.
[0294] In another embodiment, the acquisition module 110, the prediction module 120, and the determination module 130 may be a hardware-software hybrid module; the hardware-software hybrid module includes, but is not limited to, various programmable arrays; the programmable array includes, but is not limited to, field-programmable arrays and / or complex programmable arrays.
[0295] In another embodiment, the acquisition module 110, the prediction module 120, and the determination module 130 may be pure hardware modules; the pure hardware modules include, but are not limited to, application-specific integrated circuits.
[0296] In one embodiment, the apparatus includes:
[0297] The training module is used to determine the learning rate of the s-th particle in the particle swarm based on the particle swarm algorithm. It uses API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as a label to perform the x-th round of training on an LSTM model containing m hidden layer nodes to obtain the x-th prediction value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S, where S is the total number of particles in the particle swarm.
[0298] The particle error determination module 130 is used to determine the x-th error based on the difference between the x-th predicted value and the label;
[0299] The update module is used to update m or lr in the s-th particle when the x-th error does not meet the preset condition, and to perform iterative update training based on the s-th particle;
[0300] The group error module is used to determine the group error of the particle swarm based on the errors of S particles in the particle swarm that satisfy a preset condition, wherein the group error is the minimum error in the particle swarm that satisfies the preset condition.
[0301] The model determination module 130 is used to determine the number of hidden layer nodes and model parameters of the LSTM model based on the particles corresponding to the group error.
[0302] In one embodiment, the LSTM model comprises multiple stacked LSTM layers.
[0303] In one embodiment, the acquisition module 110 includes: a monitoring unit, configured to monitor relevant files of the API according to the nth monitoring configuration, wherein the relevant files include: API project files and / or documentation files;
[0304] The reading unit is used to read the updated API information when it is determined from the relevant file that the API information has been updated.
[0305] In one embodiment, the reading unit is specifically used to read API information when it is determined from the relevant file that API information has been updated during the nth time period;
[0306] The update type of the API information is determined by comparing the API information read in the nth time period with the API information collected in the (n-1)th time period.
[0307] When the API information is fully updated, all the API information read will be the API information input into the LSTM model;
[0308] When the API information is an incremental update, the incrementally updated API information is the API information input into the LSTM model.
[0309] In one embodiment, the reading unit is specifically used to obtain the nth summary information of the API information collected in the nth time period; compare the nth summary information with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period.
[0310] In one embodiment, the determining module 130 is specifically configured to increase the monitoring frequency included in the nth monitoring configuration to obtain the monitoring frequency included in the n+1th monitoring configuration when the nth predicted value increases relative to the (n-1)th predicted value corresponding to the nth monitoring configuration; or, when the nth predicted value decreases relative to the change frequency of the API information in the nth time period, decrease the monitoring frequency included in the nth monitoring configuration to obtain the monitoring frequency included in the n+1th monitoring configuration.
[0311] like Figure 11 As shown, this disclosure provides an LSTM model training apparatus including:
[0312] Training module 210 is used to determine the learning rate of the s-th particle in the particle swarm based on the particle swarm algorithm. It uses API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as a label to perform the x-th round of training on an LSTM model containing m hidden layer nodes to obtain the x-th predicted value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S. S is the total number of particles in the particle swarm. The value of x can be any positive integer.
[0313] Particle error module 220 is used to determine the x-th error based on the difference between the x-th predicted value and the label;
[0314] Update module 230 is used to update m or lr in the s-th particle when the x-th error does not meet the preset condition, and to perform iterative update training based on the s-th particle;
[0315] The group error module 240 is used to determine the group error of the particle group based on the errors of S particles in the particle group that satisfy preset conditions, wherein the group error is the minimum error in the particle group that satisfies the preset conditions.
[0316] The model determination module 250 is used to determine the number of hidden layer nodes and model parameters of the LSTM model based on the particles corresponding to the group error.
[0317] The trained LSTM model is used to predict the change frequency of API information in the next time period based on the API information collected in the previous time period. The predicted change frequency is used to determine the monitoring configuration for the next time period.
[0318] In some embodiments, the training module 210, the particle error module 220, the update module 230, the group error module 240, and the model determination module 250 may be program modules; after the program modules are executed by the processor, they can implement the operations of the above-mentioned modules.
[0319] In another embodiment, the training module 210, the particle error module 220, the update module 230, the swarm error module 240, and the model determination module 250 may be hardware-software hybrid modules; such hardware-software hybrid modules include, but are not limited to, various programmable arrays; such programmable arrays include, but are not limited to, field-programmable arrays and / or complex programmable arrays.
[0320] In another embodiment, the training module 210, the particle error module 220, the update module 230, the group error module 240, and the model determination module 250 may be pure hardware modules; the pure hardware modules include, but are not limited to, application-specific integrated circuits.
[0321] In one embodiment, the LSTM model comprises multiple stacked LSTM layers.
[0322] like Figure 12 As shown, this disclosure provides an electronic device, characterized in that the electronic device includes:
[0323] Memory;
[0324] A processor, connected to the memory, is configured to implement the methods provided in any of the foregoing embodiments by executing computer-executable instructions stored in the memory, such as performing... Figure 1 , Figure 4 , Figure 5 , Figures 8 to 9 Any of the methods shown.
[0325] The electronic device may be a terminal device and / or a server in a service platform.
[0326] like Figure 6 As shown, the electronic device may also include a network interface, which can be used to interact with peer devices via a network.
[0327] This disclosure provides a computer storage medium storing computer-executable instructions; when executed by a processor, these computer-executable instructions can implement the methods provided in any of the foregoing embodiments, for example, performing... Figure 1 , Figure 4 , Figure 5 , Figures 8 to 9 Any of the methods shown.
[0328] The technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.
[0329] In the several embodiments provided in this application, it should be understood that the disclosed methods and smart devices can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0330] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0331] In addition, each functional unit in the various embodiments of this application can be integrated into a second processing unit, or each unit can be a separate unit, or N or more units can be integrated into a unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0332] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. An application program interface (API) information processing method, characterized by, The method includes: During the nth time period, monitor the relevant files of the API according to the nth monitoring configuration, wherein the relevant files include: API project files and / or documentation files; wherein n is a positive integer; When it is determined from the relevant files that API information has been updated during the nth time period, read the API information; The update type of the API information is determined by comparing the API information read in the nth time period with the API information collected in the (n-1)th time period. Based on the update type, the updated API information is determined; wherein, when the update type is a full update, all read API information is used as the updated API information; when the update type is an incremental update, the incremental updated API information is used as the updated API information. The updated API information is input into the Long Short-Term Memory (LSTM) network model trained based on the particle swarm optimization algorithm to obtain the nth predicted value of the API change frequency. Based on the nth predicted value, the (n+1)th monitoring configuration is determined, wherein the (n+1)th monitoring configuration is used for collecting API information during the (n+1)th time period.
2. The method of claim 1, wherein, The training of the Long Short-Term Memory (LSTM) network model obtained based on the particle swarm optimization algorithm includes: The learning rate of the s-th particle in the particle swarm is determined based on the particle swarm algorithm. Using the API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as the label, the x-th round of training is performed on an LSTM model containing m hidden layer nodes to obtain the x-th predicted value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S. S is the total number of particles in the particle swarm. The value of x can be any positive integer. The x-th error is determined based on the difference between the x-th predicted value and the label; If the x-th error does not meet the preset condition, update m or lr in the s-th particle and perform iterative update training based on the s-th particle; The group error of the particle swarm is determined based on the error of S particles in the particle swarm satisfying the preset conditions, wherein the group error is the minimum error in the particle swarm that satisfies the preset conditions. Based on the particles corresponding to the group error, the number of hidden layer nodes and model parameters of the LSTM model are determined.
3. The method according to claim 1 or 2, characterized in that, The LSTM model consists of multiple stacked LSTM layers.
4. The method of claim 1, wherein, The step of determining the update type of the API information by comparing the API information read in the nth time period with the API information collected in the (n-1)th time period includes: Obtain the nth summary information of the API information collected in the nth time period; The nth summary information is compared with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period.
5. The method according to claim 4, characterized in that, The step of comparing the nth summary information with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period includes: When the nth predicted value increases relative to the (n-1)th predicted value corresponding to the nth monitoring configuration, the monitoring frequency included in the nth monitoring configuration is increased to obtain the monitoring frequency included in the (n+1)th monitoring configuration. or, When the frequency of change of the nth predicted value relative to the API information of the nth time period decreases, the monitoring frequency included in the nth monitoring configuration is reduced to obtain the monitoring frequency included in the (n+1)th monitoring configuration.
6. An application programming interface (API) information processing device, characterized in that, The device includes: The acquisition module is used to monitor relevant files of the API according to the nth monitoring configuration during the nth time period, wherein the relevant files include: API project files and / or documentation files; wherein n is a positive integer; it is also used to read API information when it is determined from the relevant files during the nth time period; it is also used to compare the API information read during the nth time period with the API information collected during the (n-1)th time period to determine the update type of the API information; it is also used to determine the updated API information according to the update type; wherein, when the update type is a full update, all read API information is used as the updated API information; when the update type is an incremental update, the incrementally updated API information is used as the updated API information. The prediction module is used to input the updated API information into the Long Short-Term Memory (LSTM) network model trained based on the particle swarm optimization algorithm to obtain the nth predicted value of the API change frequency. The determination module is used to determine the (n+1)th monitoring configuration based on the nth predicted value, wherein the (n+1)th monitoring configuration is used for collecting API information during the (n+1)th time period.
7. The apparatus according to claim 6, characterized in that, The device includes: The training module is used to determine the learning rate of the s-th particle in the particle swarm based on the particle swarm algorithm. It uses API information collected at time m as sample data and the API change frequency at time m+1 as the label. The x-th iteration of the LSTM model containing m hidden layer nodes is trained to obtain the x-th predicted value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S, where S is the total number of particles in the particle swarm. The particle error determination module is used to determine the x-th error based on the difference between the x-th predicted value and the label; The update module is used to update m or lr in the s-th particle when the x-th error does not meet the preset condition, and to perform iterative update training based on the s-th particle; The group error module is used to determine the group error of the particle swarm based on the errors of S particles in the particle swarm that satisfy a preset condition, wherein the group error is the minimum error in the particle swarm that satisfies the preset condition. The model determination module is used to determine the number of hidden layer nodes and model parameters of the LSTM model based on the particles corresponding to the group error.
8. The apparatus according to claim 6 or 7, characterized in that, The LSTM model consists of multiple stacked LSTM layers.
9. The apparatus according to claim 6, characterized in that, The reading unit is specifically used to obtain the nth summary information of the API information collected in the nth time period; compare the nth summary information with the (n-1)th summary information of the API information collected in the (n-1)th time period to determine the update type of the API information collected in the nth time period.
10. The apparatus according to claim 6 or 7, characterized in that, The determining module is specifically used to increase the monitoring frequency included in the nth monitoring configuration to obtain the monitoring frequency included in the n+1th monitoring configuration when the nth predicted value increases relative to the (n-1)th predicted value corresponding to the nth monitoring configuration; or, when the nth predicted value decreases relative to the change frequency of the API information in the nth time period, decrease the monitoring frequency included in the nth monitoring configuration to obtain the monitoring frequency included in the n+1th monitoring configuration.
11. An LSTM model training method, characterized in that, include: The learning rate of the s-th particle in the particle swarm is determined based on the particle swarm algorithm. Using the API information collected in the m-th time period as sample data and the API change frequency in the (m+1)-th time period as the label, the x-th round of training is performed on an LSTM model containing m hidden layer nodes to obtain the x-th predicted value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S. S is the total number of particles in the particle swarm. The value of x can be any positive integer. The x-th error is determined based on the difference between the x-th predicted value and the label; If the x-th error does not meet the preset condition, update m or lr in the s-th particle and perform iterative update training based on the s-th particle; The group error of the particle swarm is determined based on the error of S particles in the particle swarm satisfying the preset conditions, wherein the group error is the minimum error in the particle swarm that satisfies the preset conditions. Based on the particles corresponding to the group error, determine the number of hidden layer nodes and model parameters of the LSTM model; The trained LSTM model is used to predict the change frequency of API information in the next time period based on the API information collected in the previous time period. The predicted change frequency is used to determine the monitoring configuration for the next time period. When the API information in the previous time period is updated and the update type is full update, the API information collected in the previous time period is all the read API information. When the API information in the previous time period is updated and the update type is incremental update, the API information collected in the previous time period is the incrementally updated API information.
12. The method according to claim 11, characterized in that, The LSTM model consists of multiple stacked LSTM layers.
13. An LSTM model training device, characterized in that, include: The training module is used to determine the learning rate of the s-th particle in the particle swarm based on the particle swarm algorithm. It uses API information collected at time m as sample data and the API change frequency at time m+1 as a label to train an LSTM model containing m hidden layer nodes for the x-th round to obtain the x-th predicted value. The particle features of the s-th particle include: the number of hidden layer nodes m in the LSTM model, the learning rate lr, and s being less than or equal to S. S is the total number of particles in the particle swarm. The value of x can be any positive integer. The particle error module is used to determine the x-th error based on the difference between the x-th predicted value and the label; The update module is used to update m or lr in the s-th particle when the x-th error does not meet the preset condition, and to perform iterative update training based on the s-th particle; The group error module is used to determine the group error of the particle swarm based on the errors of S particles in the particle swarm that satisfy a preset condition, wherein the group error is the minimum error in the particle swarm that satisfies the preset condition. The model determination module is used to determine the number of hidden layer nodes and model parameters of the LSTM model based on the particles corresponding to the group error. The trained LSTM model is used to predict the change frequency of API information in the next time period based on the API information collected in the previous time period. The predicted change frequency is used to determine the monitoring configuration for the next time period. When the API information in the previous time period is updated and the update type is full update, the API information collected in the previous time period is all the read API information. When the API information in the previous time period is updated and the update type is incremental update, the API information collected in the previous time period is the incrementally updated API information.
14. The apparatus according to claim 13, characterized in that, The LSTM model consists of multiple stacked LSTM layers.
15. An electronic device, characterized in that, The electronic device includes: Memory; A processor, connected to the memory, is configured to implement the method provided by any one of claims 1 to 5 or 11 to 12 by executing computer-executable instructions stored on the memory.
16. A computer storage medium, characterized in that, The computer storage medium stores computer-executable instructions; when executed by a processor, the computer-executable instructions can implement the method provided by any one of claims 1 to 5 or 11 to 12.
Citation Information
Patent Citations
Travel time prediction method for optimizing LSTM neural network through particle swarm optimization algorithm
CN108986470A
Operation configuration parameter adjustment method and device, computer equipment and storage medium
CN111078500A
