Function-level recognition method and system for open-source UAV flight control software

By constructing multi-view features and performing adaptive weighted fusion, the problem of limited cross-platform recognition accuracy in existing technologies is solved, and more efficient function-level recognition in open-source UAV flight control software is achieved.

CN122884533BActive Publication Date: 2026-11-17CIVIL AVIATION FLIGHT UNIV OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611388643.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-09-08
Publication Date
2026-11-17
Estimated Expiration
2046-09-08

AI Technical Summary

Technical Problem

In existing technologies, conventional function-level platform identification methods cannot fully characterize the multi-dimensional attributes of open-source UAV flight control software, resulting in limited cross-platform identification accuracy.

Method used

A joint representation function of character-level lexical view, code semantic view and lightweight structural view is adopted. The soft allocation probability is solved and the transportation reliability is calculated through entropy regularization optimal transmission. The projection views are weighted and fused with dual feedback gating weights to achieve adaptive integration of multi-view features and iterative optimization of platform prototype.

Benefits of technology

It improves the accuracy of function-level platform recognition by constructing multi-view features and performing adaptive weighted fusion, optimizing model parameters and prototypes, and achieving more efficient cross-platform recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122884533B_ABST
    Figure CN122884533B_ABST
Patent Text Reader

Abstract

This application discloses a function-level recognition method and system for open-source UAV flight control software, relating to the field of data processing technology. Addressing the problem that single-view features cannot fully characterize the multi-dimensional attributes of functions, thus limiting cross-platform recognition accuracy, this method employs a three-view joint representation of the function: a character-level lexical view, a code semantic view, and a lightweight structural view. It solves for soft allocation probabilities and calculates transport reliability through entropy regularization optimal transmission, and uses dual-feedback gating weights to weighted fuse the projected views, achieving adaptive integration of multi-view features and iterative optimization of the platform prototype, thereby improving the accuracy of function-level platform recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a function-level recognition method and system for open-source UAV flight control software. Background Technology

[0002] Open-source drone flight control software is widely used in drone scenarios such as aerial photography, plant protection, inspection, and logistics. Typical platforms include open-source projects such as PX4 and ArduPilot.

[0003] The source code of these platforms is hosted in public repositories, and the developer community continuously submits functional modules and patch updates. Significant differences exist between the platforms in terms of architecture design, interface specifications, and communication protocols. During software development and maintenance, automated analysis of a large number of functions is required, including code reuse detection, vulnerability tracing, compatibility assessment, and architectural difference measurement.

[0004] Function-level platform identification is a prerequisite for the above analysis tasks. Its goal is to determine the flight control platform to which a function belongs based on the function's code characteristics.

[0005] Conventional function-level platform identification methods typically employ a single-view feature representation function, such as relying solely on lexical statistics or solely on code semantic embedding, and directly output platform labels through a shared classifier.

[0006] However, there are semantic gaps between different view features, lexical statistics have difficulty capturing code structure information, semantic embedding has limited ability to express short functions, and single view features cannot fully characterize the multi-dimensional attributes of functions, resulting in limited cross-platform recognition accuracy. Summary of the Invention

[0007] The main purpose of this application is to provide a function-level recognition method and system for open-source UAV flight control software, so as to solve the problem that conventional function-level platform recognition methods in the prior art cannot fully characterize the multi-dimensional attributes of functions, resulting in limited cross-platform recognition accuracy.

[0008] To achieve the above objectives, this application provides the following technical solution:

[0009] A function-level recognition method for open-source UAV flight control software, the function-level recognition method comprising:

[0010] Step S1: Collect fixed version source code from at least two open source UAV flight control software repositories, extract function definitions from the source files using a syntax parser, filter and remove duplicates, and then divide the data into layers according to platform tags to obtain the training dataset.

[0011] Step S2: For each function in the training dataset, construct a character-level lexical view, a code semantic view, and a lightweight structure view, and input each view into the corresponding projection network and map it to a shared space of the same dimension to obtain the projection representation of each view;

[0012] Step S3: Initialize the platform view prototype for each platform under each view, and use the distance between the projection representation and the platform view prototype as the cost to obtain the cost matrix;

[0013] Step S4: Use the cost matrix as input to solve for the transport matrix, and normalize the transport matrix by sample rows to obtain the soft allocation probability, and calculate the transport reliability of each view.

[0014] Step S5: Input the stitched representation of each projected view into the content gating network to obtain the content gating score, calibrate the transportation reliability to the content gating score to obtain the dual feedback gating weight, and then perform weighted fusion to obtain the fused representation. Input the fused representation into the classifier to obtain the platform prediction result.

[0015] Step S6: The platform prediction result, the transportation matrix, and the dual feedback gating weights are used to jointly calculate the loss and perform gradient backpropagation. The platform view prototype is then updated using exponential moving average.

[0016] Beneficial effects of steps S1 to S6:

[0017] This method addresses the limitation of cross-platform recognition accuracy caused by the inability of a single view feature to fully characterize the multi-dimensional attributes of a function. It employs character-level lexical views, code semantic views, and lightweight structural views. Figure 3 The view joint representation function solves the soft allocation probability and calculates the transport reliability through entropy regularization optimal transmission. It uses dual feedback gating weights to weight and fuse the projected views, thereby achieving adaptive integration of multi-view features and iterative optimization of the platform prototype, and improving the recognition accuracy of the function-level platform.

[0018] In this process, step S1 constructs a training dataset through syntax parsing and hierarchical partitioning to ensure sample balance; step S2 constructs three views and projects them onto a shared space to eliminate the semantic gap of a single view; step S3 constructs a cost matrix based on the distance between the projected representation and the platform view prototype to provide a quantification basis for optimal transmission; step S4 solves the soft assignment probability and calculates the transportation reliability through entropy regularization of optimal transmission to quantify the discriminative ability of each view; step S5 calibrates the content gating score with the transportation reliability to obtain dual feedback gating weights, and weighted fusion to obtain a fused representation, realizing adaptive weighting of the view; step S6 performs gradient backpropagation in conjunction with three types of losses and updates the platform view prototype through exponential moving average to achieve collaborative optimization of model parameters and prototype.

[0019] As a further improvement to this application, in step S1, fixed-version source code from at least two open-source UAV flight control software repositories is collected. Function definitions are extracted from the source files using a syntax parser, filtered for duplicates, and then hierarchically divided according to platform tags to obtain a training dataset, including:

[0020] Step S1.1: Collect fixed version source code from at least two open-source UAV flight control software repositories, record the platform tag and version identifier of each repository, and integrate them to obtain a set of source code files;

[0021] Step S1.2: Traverse the source files in the source code file set using a syntax parser to extract function names, parameter lists, and function bodies, and integrate them to obtain the original function set;

[0022] Step S1.3: Delete functions with fewer than a preset threshold and duplicate functions from the original function set to obtain a candidate function set;

[0023] Step S1.4: Count the number of samples for each platform label in the candidate function set, and divide them proportionally to obtain the training dataset.

[0024] Beneficial effects of steps S1.1 to S1.4:

[0025] This series of steps involves collecting fixed versions of source code from multiple repositories and recording platform tags and version identifiers to obtain a set of source code files, providing a unified source of source code for subsequent function extraction.

[0026] The process involves the following steps: Step S1.1: Collect fixed-version source code from multiple repositories and record platform tags and version identifiers to ensure traceability of sample sources; Step S1.2: Extract function names, parameter lists, and function bodies using a syntax parser and integrate them to obtain the original function set, achieving standardized extraction at the function level; Step S1.3: Delete functions with low line counts and duplicate functions to obtain a candidate function set and reduce noise interference; Step S1.4: Count the number of labeled samples for each platform and divide them proportionally to obtain the training dataset, maintaining the original sample proportions for each platform.

[0027] As a further improvement of this application, step S2 involves constructing a character-level lexical view, a code semantic view, and a lightweight structure view for each function in the training dataset, and inputting each view into the corresponding projection network and mapping it to a shared space of the same dimension to obtain the projection representation of each view, including:

[0028] Step S2.1: Perform character-level word segmentation on each function in the training dataset to extract character n-gram frequency features and construct a term frequency-inverse document frequency vector to obtain a character-level lexical view;

[0029] Step S2.2: Input each function in the training dataset into the pre-trained code semantic encoder to extract the last hidden state and perform mean pooling to obtain the code semantic view;

[0030] Step S2.3: Extract structural statistics such as the number of control flow edges, cyclomatic complexity, number of parameters, and maximum nesting depth for each function in the training dataset, and integrate them to obtain a lightweight structural view;

[0031] Step S2.4: Input the character-level lexical view, the code semantic view, and the lightweight structure view into the corresponding projection network and map them to a shared space of the same dimension to obtain the projection representation of each view.

[0032] Beneficial effects of steps S2.1 to S2.4:

[0033] This series of steps constructs a character-level lexical view, a code semantic view, and a lightweight structural view, and projects them onto a shared space of the same dimension to obtain the projected representation of each view, thereby eliminating the semantic gap and dimensional differences between different views.

[0034] Specifically, step S2.1 extracts character n-gram frequency features and constructs a term frequency-inverse document frequency vector to obtain a character-level lexical view, capturing the lexical statistical features of the function; step S2.2 extracts hidden states through a pre-trained code semantic encoder and performs mean pooling to obtain a code semantic view, capturing the deep semantic information of the function; step S2.3 extracts structural statistics such as the number of control flow edges, cyclomatic complexity, number of parameters, and maximum nesting depth to obtain a lightweight structural view, characterizing the structural topological features of the function; step S2.4 inputs the three views into the corresponding projection networks and maps them to a shared space of the same dimension to obtain the projection representation of each view, achieving a unified representation of multi-view features.

[0035] As a further improvement to this application, step S3 involves initializing a platform view prototype for each platform under each view, and using the distance between the projection representation and the platform view prototype as a cost to obtain a cost matrix, including:

[0036] Step S3.1: For each platform under each view, randomly select several samples from the projection representation as initial prototypes to obtain the platform view prototype;

[0037] Step S3.2: Calculate the cosine distance between the projection representation of each sample and each platform view prototype;

[0038] Step S3.3: Arrange the cosine distances according to the sample index and the platform prototype index to obtain the cost matrix.

[0039] Beneficial effects of steps S3.1 to S3.3:

[0040] This series of steps provides a quantitative basis for solving the optimal transport problem by initializing the platform view prototype for each platform under each view and calculating the cosine distance.

[0041] In step S3.1, several samples are randomly selected from the projection representation as initial prototypes to obtain platform view prototypes and establish feature anchor points for each platform. In step S3.2, the cosine distance between the projection representation of each sample and the platform view prototype is calculated to quantify the similarity between the sample and the prototype. In step S3.3, the cosine distance is arranged according to the sample index and the platform prototype index to obtain the cost matrix, and the distance relationship is structured into a computable matrix form.

[0042] As a further improvement to this application, step S4 involves solving for the transportation matrix using the cost matrix as input to entropy-regularized optimal transportation, normalizing the transportation matrix by sample rows to obtain soft allocation probabilities, and calculating the transportation reliability of each view, including:

[0043] Step S4.1: The cost matrix is ​​used as the input for entropy regularized optimal transport. The transport matrix is ​​obtained by Sinkhorn iteration with the batch sample distribution and platform prototype distribution as marginal constraints.

[0044] Step S4.2: Normalize the transportation matrix by sample rows to obtain the soft assignment probability of each sample to each platform prototype;

[0045] Step S4.3: Calculate the sum of the soft assignment probabilities of each sample being assigned to all sub-prototypes of the correct platform under each view, and calculate the average soft assignment entropy of each view.

[0046] Step S4.4: Combine the average transportation cost of each view with the average soft allocation entropy to calculate the transportation reliability of each view.

[0047] Beneficial effects of steps S4.1 to S4.4:

[0048] This series of steps obtains the transportation matrix by using the cost matrix as input for entropy-normalized optimal transportation, and calculates the transportation reliability of each view, thereby quantifying the soft allocation relationship between the sample and the platform prototype and evaluating the discrimination capability of each view.

[0049] Specifically, step S4.1 uses the batch sample distribution and platform prototype distribution as marginal constraints, and obtains the transportation matrix through Sinkhorn iteration to achieve the global optimal matching between samples and prototypes; step S4.2 normalizes the transportation matrix by sample rows to obtain the soft assignment probability of each sample to each platform prototype, transforming hard assignment into probabilistic assignment; step S4.3 calculates the sum of the soft assignment probabilities of the correct platform sub-prototypes and calculates the average soft assignment entropy to quantify the assignment determinism of each view; step S4.4 calculates the transportation reliability by combining the average transportation cost and the average soft assignment entropy, and comprehensively evaluates the discrimination quality of each view.

[0050] As a further improvement to this application, step S5 involves inputting the stitched representation of each projected view into a content gating network to obtain a content gating score, calibrating the transport reliability against the content gating score to obtain dual-feedback gating weights, then weighting and fusing them to obtain a fused representation, and inputting the fused representation into a classifier to obtain a platform prediction result, including:

[0051] Step S5.1: Stitch the projected views along the feature dimensions to obtain the stitched representation;

[0052] Step S5.2: The spliced ​​representation of the input content gating network is processed by a fully connected layer and a Sigmoid activation function to obtain the content gating score of each view;

[0053] Step S5.3: Use the transportation reliability as a reliability coefficient to perform multiplicative calibration on the content gating score to obtain the dual feedback gating weight;

[0054] Step S5.4: The projected views are weighted and summed using the dual-feedback gating weights to obtain the fused representation;

[0055] Step S5.5: Input the fused representation into the classifier, process it through a fully connected layer and a Softmax activation function to obtain the platform prediction result.

[0056] Beneficial effects of steps S5.1 to S5.5:

[0057] This series of steps involves stitching together the projected views and inputting them into a content gating network to obtain a content gating score. The weights are then calibrated with transport reliability to obtain dual-feedback gating weights. The weighted fusion is used to obtain a fused representation, which is then input into a classifier to achieve adaptive weighting of multi-view features and platform classification output.

[0058] In this process, step S5.1 involves stitching together the projected views along the feature dimension to obtain a stitched representation, preserving the complete feature information of each view. Step S5.2 inputs the stitched representation into a content gating network, processes it through a fully connected layer and a sigmoid activation function, and obtains the content gating score for each view, quantifying the feature contribution of each view. Step S5.3 uses transport reliability as a reliability coefficient to perform multiplicative calibration on the content gating score, obtaining dual-feedback gating weights, and integrating the discriminative feedback from the transmission layer into the gating mechanism. Step S5.4 uses the dual-feedback gating weights to perform a weighted summation on each projected view, obtaining a fused representation, so that views with strong discriminative ability receive higher weights. Step S5.5 inputs the fused representation into a classifier, processes it through a fully connected layer and a softmax activation function, obtains the platform prediction result, and outputs a probabilistic platform classification.

[0059] As a further improvement to this application, step S6 involves jointly calculating the loss using the platform prediction result, the transportation matrix, and the dual-feedback gating weights, performing gradient backpropagation, and updating the platform view prototype using exponential moving average, including:

[0060] Step S6.1: Calculate the cross-entropy classification loss by comparing the platform prediction results with the actual platform labels;

[0061] Step S6.2: Compare the soft allocation probability in the transportation matrix with the loss calculated from the prototype of the real platform label;

[0062] Step S6.3: Calculate the gating consistency loss by combining the content gating score in the dual feedback gating weights with the transportation reliability.

[0063] Step S6.4: The cross-entropy classification loss, the prototype contrast loss, and the gating consistency loss are weighted and summed to obtain the joint loss;

[0064] Step S6.5: Perform gradient backpropagation on the joint loss to update the parameters of each projection network, content gating network and classifier, and update the platform view prototype by exponential moving average.

[0065] Beneficial effects of steps S6.1 to S6.5:

[0066] This series of steps involves jointly calculating the loss using the platform prediction results, transportation matrix, and dual-feedback gating weights, and then performing gradient backpropagation. The platform view prototype is updated using exponential moving averages, enabling collaborative optimization and continuous iteration of model parameters and the prototype.

[0067] Specifically, step S6.1 calculates the cross-entropy classification loss by comparing the platform prediction results with the real platform labels to quantify the deviation in classification prediction; step S6.2 calculates the prototype contrast loss by comparing the soft assignment probability in the transportation matrix with the real platform labels to constrain the direction of prototype sample allocation; step S6.3 calculates the gating consistency loss by comparing the content gating score in the dual feedback gating weights with the transportation reliability to constrain the consistency between the gating weights and the transmission discrimination feedback; step S6.4 calculates the joint loss by weighted summation of the cross-entropy classification loss, prototype contrast loss, and gating consistency loss to achieve a unified metric for multi-objective optimization; and step S6.5 updates the parameters of each projection network, content gating network, and classifier by gradient backpropagation on the joint loss, and updates the platform view prototype by exponential moving average to achieve coordinated iteration of model parameters and prototype.

[0068] To achieve the above objectives, this application also provides the following technical solutions:

[0069] A function-level recognition system for open-source UAV flight control software, wherein the function-level recognition system is applied to the function-level recognition method described above, and the function-level recognition system includes:

[0070] The training dataset acquisition module is used to collect fixed versions of source code from at least two open-source drone flight control software repositories. The function definitions are extracted from the source files by a syntax parser, filtered and deduplicated, and then divided into layers according to platform tags to obtain the training dataset.

[0071] The view projection representation acquisition module is used to construct a character-level lexical view, a code semantic view, and a lightweight structure view for each function in the training dataset, and input each view into the corresponding projection network and map it to a shared space of the same dimension to obtain the projection representation of each view;

[0072] The cost matrix acquisition module is used to initialize a platform view prototype for each platform under each view, and use the distance between the projection representation and the platform view prototype as the cost to obtain the cost matrix.

[0073] The transportation reliability calculation module is used to solve for the transportation matrix by taking the cost matrix as input to the entropy regularized optimal transmission, and to normalize the transportation matrix by sample rows to obtain the soft allocation probability, and to calculate the transportation reliability of each view.

[0074] The platform prediction result acquisition module is used to input the stitched representation of each projected view into the content gating network to obtain the content gating score, calibrate the transportation reliability to the content gating score to obtain the dual feedback gating weight, and then weight and fuse them to obtain the fused representation. The fused representation is then input into the classifier to obtain the platform prediction result.

[0075] The platform view prototype update module is used to jointly calculate the loss by combining the platform prediction results, the transportation matrix, and the dual feedback gating weights, and perform gradient backpropagation, and update the platform view prototype by exponential moving average.

[0076] To achieve the above objectives, this application also provides the following technical solutions:

[0077] An electronic device includes a processor and a memory coupled to the processor, the memory storing program instructions executable by the processor; when the processor executes the program instructions stored in the memory, it implements the function-level recognition method of the open-source UAV flight control software described above.

[0078] To achieve the above objectives, this application also provides the following technical solutions:

[0079] A computer-readable storage medium storing program instructions, which, when executed by a processor, enable the function-level recognition method of the open-source UAV flight control software described above. Attached Figure Description

[0080] Figure 1 This is a flowchart illustrating the steps of an embodiment of the function-level recognition method for open-source UAV flight control software according to this application.

[0081] Figure 2 This is a functional module diagram of an embodiment of the function-level recognition system for open-source UAV flight control software according to this application;

[0082] Figure 3 This is a schematic diagram of the structure of an embodiment of the electronic device of this application;

[0083] Figure 4 This is a schematic diagram of the structure of one embodiment of the storage medium of this application. Detailed Implementation

[0084] 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 a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0085] The terms "first," "second," and "third" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. All directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of this application are only used to explain the relative positional relationships and movements between components in a specific orientation (e.g., as shown in the figures). If the specific orientation changes, the directional indications also change accordingly. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive having. For example, a process, method, system, product, or device having a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.

[0086] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be present in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0087] It should be noted that, due to the limited types and number of symbols or letters that can represent specific meanings, for embodiments with many formulas or codes, there may be situations where symbols or letters cannot meet the usage requirements. Therefore, the interpretation of formula symbols in the steps or sub-steps of the embodiments is only valid for the current step or sub-step.

[0088] If the same symbol has different interpretations in different steps or sub-steps, the interpretation in the current step or sub-step shall prevail; if the same symbol appears in different steps or sub-steps, but no interpretation is given in subsequent steps or sub-steps after its first appearance, the interpretation in the first step or sub-step shall be used.

[0089] For example, "i=1,2,...,n" is a writing convention and a well-known meaning. If "i=1,2,...,n" has already appeared once in an embodiment and needs to be used again in formulas with different scenarios and meanings in the future, then the meaning of "i=1,2,...,n" should be interpreted according to the corresponding formulas. If "i=1,2,...,n" is not used for the first time and is changed to a symbol or letter with a non-well-known meaning, such as "p=1,2,...,q", to avoid repetition, it is more likely to cause confusion, ambiguity, and unclear problems.

[0090] like Figure 1 As shown, this embodiment provides an example of a function-level recognition method for open-source UAV flight control software. In this embodiment, the function-level recognition method includes the following steps:

[0091] Step S1: Collect fixed-version source code from at least two open-source drone flight control software repositories, extract function definitions from the source files using a syntax parser, filter and remove duplicates, and then divide the data into layers according to platform tags to obtain the training dataset.

[0092] Furthermore, step S1 specifically includes the following steps:

[0093] Step S1.1: Collect fixed version source code from at least two open-source UAV flight control software repositories, record the platform tag and version identifier of each repository, and integrate them to obtain a set of source code files.

[0094] Preferably, the core of this step is to collect source code from multiple repositories and annotate metadata. By cloning a fixed version of the flight control software repository from a public code hosting platform and recording the platform tag and version identifier, a set of source code files with clear origin and traceable version is provided for subsequent function extraction.

[0095] For open-source drone flight control software repositories, PX4 and ArduPilot, two mainstream open-source flight control software projects, were selected as data sources. The PX4 repository address is https: / / github.com / PX4 / PX4-Autopilot, and the ArduPilot repository address is https: / / github.com / ArduPilot / ardupilot. Source code of specified release versions of each was collected.

[0096] For platform tags, the PX4 platform tag is denoted as... The ArduPilot platform is tagged as The version identifier uses Git tag numbers, for example, PX4 selects version v1.14.0, and ArduPilot selects version Copter-4.5.0.

[0097] For the source code acquisition method, the Git command-line tool is used to clone the repository by a specified version tag. The cloning command is `git clone --branch`. <tag>--depth 1, retrieves only snapshot files of the specified version, the result is a collection of source code files. It contains all the source code files from each repository.

[0098] Preferably, the PX4 repository source code files are approximately The ArduPilot repository contains approximately [number] source code files. There are [number] source code files in .c, .cpp, .h, and .hpp formats. The collected results are stored according to repository categories, and each file records its platform tag. With version identifier .

[0099] For example, during a data collection process, version 1.14.0 of the PX4 repository was cloned. Each source code file is uniformly tagged with the platform label. The version identifier is marked as v1.14.0; it was cloned from the ArduPilot repository Copter-4.5.0. Each source code file is uniformly tagged with the platform label. The version identifier is marked as Copter-4.5.0, and the resulting collection of source code files is obtained through integration. common The file has a corresponding timestamp record of YYYY-MM-DD-HH:MM:SS-001.

[0100] Step S1.2: Traverse the source files in the source code file set using a syntax parser to extract function names, parameter lists, and function bodies, and integrate them to obtain the original function set.

[0101] Preferably, the core of this step is to complete the standardized extraction at the function level. The parser traverses all source files in the source code file set, parses the abstract syntax tree, and extracts the function name, parameter list, and function body of the function definition, and integrates them to obtain the original function set.

[0102] For the syntax parser, the Tree-sitter incremental parsing library is used to build a multi-language syntax parser. Tree-sitter supports C and C++ syntax parsing. It builds an abstract syntax tree for each source code file, traverses the syntax tree nodes to locate the function definition node (function_definition), and extracts the function name (identifier), parameter list (parameter_list), and function body (compound_statement) from the function definition node.

[0103] Specifically, for the function extraction process, the set of source code files... Each source file in Perform syntax parsing and extract function definition triples. ,in The function name. For the parameter list, The function body text, with all triples combined into a primitive function set. ,in This represents the total number of functions extracted.

[0104] Preferably, the Tree-sitter parser version is v0.22.0, the C language syntax package is tree-sitter-cv0.21.0, and the C++ language syntax package is tree-sitter-cpp v0.22.0. During the parsing process, macro-defined functions and function declarations within conditional compilation branches are ignored, and only functions with complete function body definitions are extracted.

[0105] For example, during a certain parsing process, the PX4 repository version v1.14.0... The source code file was extracted after being parsed by Tree-sitter. Function definitions, ArduPilot repository, Copter-4.5.0 version. The source code file was parsed and extracted. Each function definition is integrated to obtain the original function set. common Each function defines a triplet, and each triplet is recorded in the following format: The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-002.

[0106] Step S1.3: Delete functions with fewer than a preset threshold and duplicate functions from the original function set to obtain a candidate function set.

[0107] Preferably, the core of this step is to filter noise functions and remove duplicate functions. By deleting short functions with fewer than a preset threshold and duplicate functions with identical content, noise interference is reduced and redundant samples are decreased, resulting in a set of candidate functions.

[0108] For row number filtering, the statistics for each function are calculated. Source code lines Delete those that meet the requirements The function, where To set a preset line count threshold, short functions are typically empty function bodies, single-line return statements, or simple wrapper functions, which contribute little to the platform's recognition.

[0109] For deduplication of duplicate functions, the filtered functions are compared according to the normalized hash value of the function body text. The normalization process includes deleting whitespace characters and comments and then calculating the MD5 hash. Only one function with the same hash value is kept, and the rest of the duplicate functions are deleted.

[0110] Preferably, a preset row number threshold is used. Okay, the normalized hash algorithm uses MD5, and the hash value data type is... Hexadecimal string.

[0111] For example, in a certain filtering process, the original set of functions common A function, where the number of rows is less than The functions for rows are One was deleted, the remaining ones The function was deleted after being deduplicated using MD5 hashing. By repeating the function, a candidate function set is finally obtained. common Functions, including those for the PX4 platform ArduPilot platform One, corresponding to the timestamp record YYYY-MM-DD-HH:MM:SS-003.

[0112] Step S1.4: Count the number of samples for each platform label in the candidate function set, and divide them proportionally to obtain the training dataset.

[0113] Preferably, the core of this step is to divide the data according to the hierarchical ratio of platform labels. By counting the number of samples from each platform in the candidate function set and dividing them according to a set ratio, the distribution of samples from each platform in the training dataset is ensured to be balanced.

[0114] Among them, for hierarchical partitioning, the set of candidate functions is statistically analyzed. Chinese platform tags Number of samples According to the division ratio The functions of each platform are divided into training datasets, using the following formula:

[0115] .

[0116] in, For the platform The number of samples allocated to the training dataset. For the platform The number of samples in the candidate function set. Divide the training set into proportions. This is the floor function.

[0117] Preferably, the training set partitioning ratio The partitioning employs random sampling without disrupting the hierarchical structure of platform labels; that is, each platform is independently partitioned proportionally and then merged into the training dataset. .

[0118] For example, in a certain partitioning process, the candidate function set common Functions, including those for the PX4 platform ArduPilot platform One, according to Partitioning, PX4 platform training set One, ArduPilot platform training set The dataset is obtained by merging the individual datasets. common The function corresponds to the timestamp record YYYY-MM-DD-HH:MM:SS-004.

[0119] Beneficial effects of steps S1.1 to S1.4:

[0120] This series of steps involves collecting fixed versions of source code from multiple repositories and recording platform tags and version identifiers to obtain a set of source code files, providing a unified source of source code for subsequent function extraction.

[0121] The process involves the following steps: Step S1.1: Collect fixed-version source code from multiple repositories and record platform tags and version identifiers to ensure traceability of sample sources; Step S1.2: Extract function names, parameter lists, and function bodies using a syntax parser and integrate them to obtain the original function set, achieving standardized extraction at the function level; Step S1.3: Delete functions with low line counts and duplicate functions to obtain a candidate function set and reduce noise interference; Step S1.4: Count the number of labeled samples for each platform and divide them proportionally to obtain the training dataset, maintaining the original sample proportions for each platform.

[0122] Step S2: For each function in the training dataset, construct a character-level lexical view, a code semantic view, and a lightweight structure view, and input each view into the corresponding projection network and map it to a shared space of the same dimension to obtain the projection representation of each view.

[0123] Furthermore, step S2 specifically includes the following steps:

[0124] Step S2.1: Perform character-level word segmentation on each function in the training dataset to extract character n-gram frequency features and construct a term frequency-inverse document frequency vector to obtain a character-level lexical view.

[0125] Preferably, the core of this step is to extract character-level lexical features of the function. By performing character-level word segmentation on the source code text of each function in the training dataset and extracting character n-gram frequency features, a word frequency-inverse document frequency vector is constructed to obtain a character-level lexical view.

[0126] For character-level word segmentation, the function body text is... Treating it as a character sequence, it is segmented at the character level, and after removing newline and tab characters, the visible character sequence is retained. ,in For the first One character, The total number of characters in the function body.

[0127] Specifically, for character n-gram frequency features, a sliding window of length is used to extract the feature from the character sequence. Given n-gram fragments of characters, count the frequency of each n-gram fragment in the current function, and construct an n-gram frequency vector. The formula for calculating frequency is:

[0128] .

[0129] in, n-gram fragments The normalized frequency in the current function. n-gram fragments In character sequence The number of times it appears in For the current function, the length is The total number of n-gram segments.

[0130] Specifically, for the term frequency-inverse document frequency vector, the n-gram frequency features are weighted according to the term frequency-inverse document frequency scheme to construct a TF-IDF vector. The formula for calculating TF-IDF is:

[0131] .

[0132] in The TF-IDF weights of the n-gram segment g are... This represents the number of times the segment appears in the current function. The total number of functions in the training dataset, This represents the number of functions that contain this segment.

[0133] Preferably, the length of the character n-gram The three lengths of n-gram frequency vectors are concatenated to form a complete term frequency-inverse document frequency vector. Vector dimension The dimension is implemented using the TF-IDF library sklearn.feature_extraction.text.TfidfVectorizer, with the maximum number of features set to 1. .

[0134] For example, in a certain process, the training dataset common A function is used to perform character-level word segmentation on the text of a function body on the PX4 platform to obtain a character sequence. Length is After extracting 2-gram, 3-gram, and 4-gram frequency features, TF-IDF vectors are constructed. Dimensions Non-zero elements One, corresponding to the timestamp record YYYY-MM-DD-HH:MM:SS-005.

[0135] Step S2.2: Input each function in the training dataset into the pre-trained code semantic encoder to extract the last hidden state and perform mean pooling to obtain the code semantic view.

[0136] Preferably, the core of this step is to extract deep semantic features of the function. By inputting the source code text of each function into a pre-trained code semantic encoder, the last hidden state is extracted and mean pooling is performed along the sequence dimension to obtain the code semantic view.

[0137] Specifically, for the pre-trained code semantic encoder, the CodeBERT model is used. CodeBERT is based on the Transformer encoder architecture and is pre-trained on code corpora, enabling it to capture deep semantic information of functions and analyze function body text. After word segmentation, the input is fed into the CodeBERT encoder, and the output is the hidden state vector for each token.

[0138] Specifically, for hidden state extraction and mean pooling, the output of the last layer of the CodeBERT encoder is a sequence of hidden states. ,in For the first The hidden state vector of each token, Given the length of the token sequence, the mean pooling formula is:

[0139] .

[0140] in, This is the code semantic view vector after mask mean pooling. For the first The hidden state vector of each token, Attention mask; valid token correspondence =1, fill in the corresponding Token. =0, This represents the length of the batch processed sequence. This approach avoids padding tokens that pollute the semantic representation.

[0141] Preferably, the CodeBERT model uses Microsoft / CodeBERT-Base pre-trained weights, and the hidden layer dimension is... Maximum Token Sequence Length Mean pooling is performed along the sequence dimension, and the output is a code semantic view vector. Dimensions dimension.

[0142] For example, in one processing step, CodeBERT segmentation was performed on the text of a function body on the PX4 platform to obtain the token sequence length. The hidden state sequence is obtained through forward propagation of the CodeBERT encoder. Dimensions After mean pooling, the code semantic view is obtained. Dimensions The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-006.

[0143] Step S2.3: Extract structural statistics such as the number of control flow edges, cyclomatic complexity, number of parameters, and maximum nesting depth for each function in the training dataset, and integrate them to obtain a lightweight structural view.

[0144] Preferably, the core of this step is to extract the structural topological features of the function. By using a syntax parser, four types of structural statistics are extracted from the abstract syntax tree of the function: the number of control flow edges, cyclomatic complexity, number of parameters, and maximum nesting depth. These are then integrated to obtain a lightweight structural view.

[0145] Among them, for the number of control flow edges A control flow graph is constructed on the abstract syntax tree of the function, and the number of directed edges in the control flow graph is counted. The control flow edges reflect the jump relationships between basic blocks within the function.

[0146] Among them, for cyclomatic complexity The cyclomatic complexity is calculated based on the control flow graph. The formula for calculating cyclomatic complexity is:

[0147] .

[0148] in, To control the number of directed edges in the flow graph, To control the number of nodes in the flow graph, To control the number of connected components in the flow graph.

[0149] Among them, regarding the number of parameters The number of parameters is counted from the parameter_list of the function definition node.

[0150] Among them, for the maximum nesting depth Traverse the abstract syntax tree to count the maximum nesting level of control statements (if, for, while, switch).

[0151] Preferably, structural statistics are integrated into a lightweight structural view vector. Vector dimension The control flow graph is constructed using a tree-sitter syntax tree node traversal method.

[0152] For example, in a certain processing step, structural statistics were extracted from a function on the PX4 platform to control the number of flow edges. Cyclic complexity Number of parameters Maximum nesting depth The integrated lightweight structural view is obtained. The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-007.

[0153] Step S2.4: Input the character-level lexical view, code semantic view, and lightweight structure view into the corresponding projection network and map them to a shared space of the same dimension to obtain the projection representation of each view.

[0154] Preferably, the core of this step is to complete the unified dimensional mapping of multi-view features. By inputting the character-level lexical view, code semantic view, and lightweight structure view into the corresponding projection network, the view features of different dimensions are mapped to the shared space of the same dimension, thus obtaining the projection representation of each view.

[0155] For the projection network, the three views correspond to independent projection networks, and the character-level lexical view corresponds to the projection network. A two-layer fully connected layer structure is adopted, and the projection network corresponding to the code semantic view is used. Employing a two-layer fully connected structure, a lightweight structural view corresponds to the projection network. A two-layer fully connected structure is adopted, with each projection network ending with a LayerNorm layer and a ReLU activation function. The projection formula is as follows:

[0156] .

[0157] in, For view The projection representation, For view The corresponding projection network, For view The input feature vector, For projection networks The parameters, .

[0158] For the shared spatial dimension, the output dimension of the three projection networks is unified as follows: In this dimension, the projected views are all located in a shared space of the same dimension, allowing for direct subsequent distance calculations and optimal transmission solutions.

[0159] Preferably, the hidden layer dimension of the projection network Output dimension The fully connected layers use the ReLU activation function, the projected network parameters are initialized using Xavier, and the normalization dimension of LayerNorm is [value missing]. dimension.

[0160] For example, in a certain processing step, a character-level lexical view of a function on the PX4 platform. Dimension via projection network Mapping yields the projected representation Dimension Code semantic view Dimension via projection network Mapping yields the projected representation Dimension Lightweight structural view Dimension via projection network Mapping yields the projected representation Dimension All three projections are in In the shared space, the corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-008.

[0161] Beneficial effects of steps S2.1 to S2.4:

[0162] This series of steps constructs a character-level lexical view, a code semantic view, and a lightweight structural view, and projects them onto a shared space of the same dimension to obtain the projected representation of each view, thereby eliminating the semantic gap and dimensional differences between different views.

[0163] Specifically, step S2.1 extracts character n-gram frequency features and constructs a term frequency-inverse document frequency vector to obtain a character-level lexical view, capturing the lexical statistical features of the function; step S2.2 extracts hidden states through a pre-trained code semantic encoder and performs mean pooling to obtain a code semantic view, capturing the deep semantic information of the function; step S2.3 extracts structural statistics such as the number of control flow edges, cyclomatic complexity, number of parameters, and maximum nesting depth to obtain a lightweight structural view, characterizing the structural topological features of the function; step S2.4 inputs the three views into the corresponding projection networks and maps them to a shared space of the same dimension to obtain the projection representation of each view, achieving a unified representation of multi-view features.

[0164] Step S3: Initialize the platform view prototype for each platform under each view, and use the distance between the projection representation and the platform view prototype as the cost to obtain the cost matrix.

[0165] Furthermore, step S3 specifically includes the following steps:

[0166] Step S3.1: For each platform under each view, randomly select several samples from the projection representation as initial prototypes to obtain the platform view prototype.

[0167] Preferably, the core of this step is to initialize the platform view prototype. By randomly selecting several samples from the projection representation for each platform under each view as the initial prototype, feature anchor points for each platform under each view are established.

[0168] Specifically, for the platform view prototype initialization, let the platform collection be... ,in The number of platforms, the view collection is For each platform In each view Below, the projection representation set of this view from the platform. Random selection One sample is used as the initial prototype, and the platform view prototype is denoted as... ,in For the sample The authentic platform label.

[0169] Among them, for the number of prototypes Each platform initializes under each view. The prototype Each sub-prototype collectively represents the feature distribution of the platform under this view. All platform view prototypes constitute the prototype tensor. .

[0170] Preferably, the number of platforms Number of sub-prototypes per platform under each view Projection represents dimension The prototype initialization uses random sampling, and a random seed is set before sampling to ensure reproducibility.

[0171] For example, during a certain initialization process, the PX4 platform, under the character-level lexical view, from Randomly selected from the projected representation of each training sample One sample was used as the initial prototype. to The ArduPilot platform, under the code semantic view, from Randomly selected from the projected representation of each training sample One sample was used as the initial prototype. to ,all The platform view prototype initialization is complete, and the corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-009.

[0172] Step S3.2: Calculate the cosine distance between the projected representation of each sample and the prototype view of each platform.

[0173] Preferably, the core of this step is to quantify the similarity between the sample and the prototype. This is achieved by calculating the cosine distance between the projected representation of each sample and all platform view prototypes, thereby quantifying the degree of similarity between the sample and each platform prototype.

[0174] For cosine distance calculation, the sample In view Projection representation below With the platform The Individual prototype Cosine distance between The calculation formula is:

[0175] .

[0176] in, Cosine distance For the sample In view The projection representation below, For the platform In view The next The prototype For vector dot product operation, Let L2 norm be the vector, and cosine distance take values ​​in the range of . .

[0177] Specifically, for distance calculation scale, each sample in each view needs to be compared with... The cosine distance is calculated for each prototype, and the distance calculation is performed on all samples across all views. .

[0178] Preferably, the cosine distance calculation is implemented using vectorization, and the L2 norm is pre-normalized before calculation. After normalization, the cosine distance is simplified to... The dot product computation framework uses PyTorch tensor operations for acceleration.

[0179] For example, in a certain calculation, the training dataset common There are 1 function, each function in Each view has a projection representation, and each view is related to... The cosine distance is calculated for each platform view prototype, and the total number of distance calculations is [number missing]. Next, the projection representation of a PX4 sample under a character-level lexical view. Compared to the PX4 platform Individual prototype cosine distance The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-010.

[0180] Step S3.3: Arrange the cosine distances according to the sample index and the platform prototype index to obtain the cost matrix.

[0181] Preferably, the core of this step is to complete the structured arrangement of distance relationships. By arranging the cosine distances in matrix form according to the sample index and the platform prototype index, the distance relationships are structured into a computable cost matrix.

[0182] Among them, for the construction of the cost matrix, the view The cost matrix below Each element is the cosine distance between the corresponding sample and the corresponding platform prototype, and the cost matrix is... for:

[0183] .

[0184] in, For view Lower sample With the platform The Cosine distance between individual prototypes For sample index, For platform prototype index, cost matrix The dimension is .

[0185] Preferably, the dimension of the cost matrix is... The cost matrix data type is Floating-point numbers, each view independently constructs a cost matrix, totaling A cost matrix.

[0186] For example, a view during a certain construction The cost matrix below Dimensions , of which The row corresponds to the first row in the training dataset. One sample and The cosine distance of the platform view prototype, the first Listed to number The column corresponds to the PX4 platform. The prototype, the first Listed to number The column corresponds to the ArduPilot platform. A prototype, a certain PX4 sample Line 1 The cost of the column The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-011.

[0187] Beneficial effects of steps S3.1 to S3.3:

[0188] This series of steps provides a quantitative basis for solving the optimal transport problem by initializing the platform view prototype for each platform under each view and calculating the cosine distance.

[0189] In step S3.1, several samples are randomly selected from the projection representation as initial prototypes to obtain platform view prototypes and establish feature anchor points for each platform. In step S3.2, the cosine distance between the projection representation of each sample and the platform view prototype is calculated to quantify the similarity between the sample and the prototype. In step S3.3, the cosine distance is arranged according to the sample index and the platform prototype index to obtain the cost matrix, and the distance relationship is structured into a computable matrix form.

[0190] Step S4: Use the cost matrix as input to solve for the transport matrix, and normalize the transport matrix by sample rows to obtain the soft allocation probability. Calculate the transport reliability of each view.

[0191] Furthermore, step S4 specifically includes the following steps:

[0192] Step S4.1: The cost matrix is ​​used as the input for entropy-normalized optimal transport. The transport matrix is ​​obtained by solving the Sinkhorn iteration with the batch sample distribution and platform prototype distribution as marginal constraints.

[0193] Preferably, the core of this step is to solve the global optimal transmission problem between the sample and the platform prototype. By using the cost matrix as input to the entropy regularized optimal transmission problem, and taking the batch sample distribution and the platform prototype distribution as marginal constraints, the transport matrix is ​​obtained by using the Sinkhorn iterative algorithm.

[0194] For entropy-normalized optimal transmission, given a view The cost matrix below ,in This refers to the batch sample size. Given the total number of platform prototypes, the entropy-regularized optimal transmission problem is:

[0195] .

[0196] in, For view The following transportation matrix For the sample With prototype The cost of the cosine distance between them Here is the entropy regularization coefficient. To satisfy edge constraints and The set of transportation matrices, This is the batch sample distribution vector. This represents the platform prototype distribution vector. To ensure that the uniform platform prototype edge distribution aligns with the batch class distribution, class-balanced sampling is used for each training batch.

[0197] Specifically, the Sinkhorn iterative solution involves alternately updating the row scaling vector. With column scaling vector The iterative solution to the transportation matrix is ​​achieved using the following formula:

[0198] .

[0199] .

[0200] in, and The first The row scaling vector and column scaling vector for the next iteration. This is the batch sample distribution vector. This is the platform prototype distribution vector. For the kernel matrix, Transportation matrix , This is a constructor for diagonal matrices.

[0201] Preferably, the entropy regularization coefficient Sinkhorn iteration count Next, batch sample distribution For uniform distribution Platform prototype distribution For uniform distribution Convergence threshold nuclear matrix The cost matrix is ​​numerically stabilized before calculation.

[0202] For example, in a certain solution, the view The cost matrix below Dimensions Batch sample quantity Total number of platform prototypes nuclear matrix ,through After the Sinkhorn iterations converge, the transport matrix is ​​obtained. Dimensions The sum of the elements in each row of the transport matrix is The sum of the elements in each column is The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-012.

[0203] Step S4.2: Normalize the transport matrix by sample rows to obtain the soft assignment probability of each sample to each platform prototype.

[0204] Preferably, the core of this step is to complete the row normalization of the transportation matrix. By normalizing the transportation matrix according to the sample rows, the transportation weights are transformed into the soft assignment probability of each sample to each platform prototype.

[0205] Among them, for row normalization, the transport matrix The sum of each row of elements may not be exactly equal. Normalizing by sample rows yields a soft-assignment probability matrix. The normalization formula is:

[0206] .

[0207] in, For the sample For the prototype The soft assignment probability, For samples in the transport matrix With prototype The transport weight between them The sum of the soft-assignment probabilities for each row is the total number of platform prototypes. .

[0208] Preferably, the soft-assignment probability matrix The dimension is consistent with the transportation matrix. Normalization is performed along the row direction, and numerical stabilization is achieved by adding a variable to the denominator. Prevent division by zero.

[0209] For example, in a certain normalization, the transport matrix No. The sum of the elements in the row is Normalized soft-assignment probability , , , ,all The sum of the probabilities of each soft assignment is The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-013.

[0210] Step S4.3: Calculate the sum of the soft assignment probabilities of each sample being assigned to all sub-prototypes of the correct platform under each view, and calculate the average soft assignment entropy of each view.

[0211] Preferably, the core of this step is to quantify the deterministic nature of the allocation of each view. This is achieved by summing the soft allocation probabilities of each sample being assigned to all sub-prototypes of the correct platform under each view and calculating the average soft allocation entropy.

[0212] Among them, the sum of the soft assignment probabilities of all sub-prototypes for the correct platform, the sample The real platform label is In view Lower sample For the correct platform The sum of the soft assignment probabilities of all sub-prototypes is , The larger the value, the larger the view. For the sample The stronger the ability to distinguish, the better.

[0213] Among them, for the average soft-assignment entropy, the view Average soft partitioning entropy of all samples The calculation formula is:

[0214] .

[0215] in, For view Average soft-assignment entropy, For the sample For the prototype The soft assignment probability, This refers to the batch sample size. For the total number of platform prototypes, a smaller average soft allocation entropy indicates a higher view size. The higher the certainty of the allocation.

[0216] Preferably, in the calculation of average soft partition entropy, the following applies: Item Plus prevent The soft-assignment probability data type is Floating-point numbers.

[0217] For example, in a certain statistical analysis, the view Next batch Average soft partitioning entropy of each sample ,view Down ,view Down The lowest entropy of a semantic view indicates the highest determinism in its allocation, corresponding to the timestamp record YYYY-MM-DD-HH:MM:SS-014.

[0218] Step S4.4: Combine the average transportation cost and average soft allocation entropy of each view to calculate the transportation reliability of each view.

[0219] Preferably, the core of this step is to comprehensively evaluate the discrimination quality of each view, and calculate the transportation reliability by combining the average transportation cost and average soft allocation entropy of each view, so as to comprehensively reflect the discrimination capability of each view.

[0220] Among them, for the average transportation cost, the view Average transportation cost The weighted average cost between all samples and all prototypes within a batch is calculated using the following formula:

[0221] .

[0222] in, For view Average transportation cost For the sample With prototype The cost of the cosine distance between them For the sample For the prototype The soft assignment probability, This refers to the batch sample size. This represents the total number of platform prototypes.

[0223] Specifically, for transportation reliability, the average transportation cost and the average soft allocation entropy are jointly used to calculate the transportation reliability. The calculation formula is:

[0224] .

[0225] in, For view Transportation reliability, For view Average transportation cost For view Average soft-assignment entropy, transport reliability The range of values ​​is The higher the transportation reliability, the better the view. The higher the discrimination quality, the better.

[0226] Preferably, in this embodiment, the average transportation cost and the average soft allocation entropy are used directly to calculate the transportation reliability without performing additional normalization, so that it is consistent with the subsequent reliability numerical examples.

[0227] For example, in a certain calculation, the view Average transportation cost Average soft-assigned entropy Transportation reliability ;view of ;view of The semantic view has the highest transport reliability, and the corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-015.

[0228] Beneficial effects of steps S4.1 to S4.4:

[0229] This series of steps obtains the transportation matrix by using the cost matrix as input for entropy-normalized optimal transportation, and calculates the transportation reliability of each view, thereby quantifying the soft allocation relationship between the sample and the platform prototype and evaluating the discrimination capability of each view.

[0230] Specifically, step S4.1 uses the batch sample distribution and platform prototype distribution as marginal constraints, and obtains the transportation matrix through Sinkhorn iteration to achieve the global optimal matching between samples and prototypes; step S4.2 normalizes the transportation matrix by sample rows to obtain the soft assignment probability of each sample to each platform prototype, transforming hard assignment into probabilistic assignment; step S4.3 calculates the sum of the soft assignment probabilities of the correct platform sub-prototypes and calculates the average soft assignment entropy to quantify the assignment determinism of each view; step S4.4 calculates the transportation reliability by combining the average transportation cost and the average soft assignment entropy, and comprehensively evaluates the discrimination quality of each view.

[0231] Step S5: Input the stitched representation of each projected view into the content gating network to obtain the content gating score, calibrate the transport reliability against the content gating score to obtain the dual feedback gating weights, then perform weighted fusion to obtain the fused representation, and input the fused representation into the classifier to obtain the platform prediction result.

[0232] Furthermore, step S5 specifically includes the following steps:

[0233] Step S5.1: Stitch together the projected views along the feature dimensions to obtain the stitched representation.

[0234] Preferably, the core of this step is to complete the dimensional stitching of multi-view features. By stitching each projected view along the feature dimension into a unified long vector, the complete feature information of each view is preserved.

[0235] Among them, for feature dimension concatenation, samples The projection representations in the three views are as follows: , , All dimensions are The concatenated representation is obtained by concatenating along the feature dimensions. The splicing formula is:

[0236] .

[0237] in, For the sample The splicing representation, This is a concatenation operation along the feature dimension, resulting in a concatenated dimension of... dimension.

[0238] Preferably, the concatenation order is: character-level lexical view first, code semantic view in the middle, and lightweight structure view last. The concatenation operation is performed along the feature dimension without changing the feature values ​​inside each view.

[0239] For example, three projected views of a sample from the PX4 platform during a stitching process. , , each Dimensions, pieced together Dimensions Dimension, of which the first to Dimensions from lexical view, the first to Dimensions come from semantic views, the first to The dimension comes from the structure view, and the corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-016.

[0240] Step S5.2: The concatenated representation of the input content gating network is processed by a fully connected layer and a Sigmoid activation function to obtain the content gating score of each view.

[0241] Preferably, the core of this step is to quantify the contribution of each view feature. This is achieved by concatenating the input content gating network, processing it through a fully connected layer and a Sigmoid activation function, and outputting the content gating score of each view.

[0242] For the content gating network, a single fully connected layer with a sigmoid activation function is used, and the input is a concatenated representation. Dimension The output is Each gating score corresponds to three views. The forward calculation formula for the content gating network is:

[0243] .

[0244] in, For the sample The content gating score vector dimension is , For the weight matrix of the gated network, This is the bias vector for the gated network. Sigmoid activation function The range of scores for each gate is: .

[0245] Preferably, the content gating network weight matrix Initialize using Xavier, bias vector Initialized as a zero vector, the output range of the Sigmoid activation function. .

[0246] For example, the spliced ​​representation of a sample on the PX4 platform in a certain calculation. Dimension The content gating score is calculated by the content gating network. These correspond to the gating scores of the lexical view, semantic view, and structural view, respectively. The highest semantic view score indicates the greatest feature contribution, and the corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-017.

[0247] Step S5.3: Use the transportation reliability as the reliability coefficient to perform multiplicative calibration on the content gating score to obtain the dual feedback gating weight.

[0248] Preferably, the core of this step is to integrate the transmission layer discrimination feedback and gating mechanism. By using the transport reliability as a reliability coefficient to perform multiplicative calibration on the content gating score, a dual feedback gating weight is obtained.

[0249] Among them, for multiplicative reliability calibration, the transport reliability will be... Content gating score is used as a reliability coefficient. Scaling, dual-feedback gating weights The calculation formula is:

[0250] .

[0251] in, For the sample In view Dual feedback gating weights, For the sample In view The following content is subject to gating scores. For view Transportation reliability, Let the set of views be the denominator, and the normalization term ensures that the sum of the double-feedback gating weights of the three views is 0. .

[0252] Preferably, the reliability coefficient scaling adopts a multiplicative calibration method, and the transportation reliability... The value range is (0,1]. After calibration, the view gating score with strong discrimination ability is amplified, while the view gating score with weak discrimination ability is compressed.

[0253] For example, the transport reliability of three views in a certain calibration. , , Content gating score , , Calibrated dual-feedback gating weights , , The semantic view has the highest weight, and the corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-018.

[0254] Step S5.4: Weighted summation of each projected view using dual-feedback gating weights to obtain the fused representation.

[0255] Preferably, the core of this step is to perform adaptive weighted fusion of multi-view features. By using dual-feedback gating weights to perform weighted summation on each projected view, the view with strong discriminative ability is given a higher weight to obtain the fused representation.

[0256] Among them, for weighted summation, the sample fusion representation The weighted sum of the three projected views using dual-feedback gating is calculated using the following formula:

[0257] .

[0258] in, For the sample The fusion representation, For the sample In view Dual feedback gating weights, For the sample In view The projection representation below, For a collection of views, merge the representation dimensions and each projected view. Figure 1 To be dimension.

[0259] Preferably, the sum of the weights of the dual-feedback gating system is confirmed before the weighted summation. The fusion represents the data type as Floating-point numbers.

[0260] For example, the dual-feedback gating weights of a sample on the PX4 platform in a certain fusion. , , The weighted summation yields the fusion representation. The fusion representation dimension is The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-019.

[0261] In step S5.5, the fused representation is input to the classifier, processed by a fully connected layer and a Softmax activation function to obtain the platform prediction result.

[0262] Preferably, the core of this step is to complete the probabilistic output of platform classification. This is achieved by inputting the fused representation into the classifier, processing it through a fully connected layer and a Softmax activation function, and outputting the probability distribution of each platform as the platform prediction result.

[0263] The classifier employs a single fully connected layer with a Softmax activation function, and its input is a fused representation. Dimension The output is The probability values ​​for each platform are calculated using the forward pass formula of the classifier:

[0264] .

[0265] in, For the sample The platform prediction results vector dimension is , The classifier weight matrix is... For the classifier bias vector, the Softmax function The output is normalized to a probability distribution.

[0266] Preferably, the classifier weight matrix Initialize using Xavier, bias vector Initialized as a zero vector, the sum of probabilities for each platform is output by Softmax. The predicted category is the platform label corresponding to the highest probability.

[0267] For example, the fusion representation of a sample from the PX4 platform in a certain classification. Dimension The platform prediction result is obtained after processing by the fully connected layer of the classifier and the Softmax activation function. , corresponding to the probabilities of PX4 and ArduPilot respectively, with the highest probability For the PX4 platform, the prediction results are consistent with the actual labels, and the corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-020.

[0268] Beneficial effects of steps S5.1 to S5.5:

[0269] This series of steps involves stitching together the projected views and inputting them into a content gating network to obtain a content gating score. The weights are then calibrated with transport reliability to obtain dual-feedback gating weights. The weighted fusion is used to obtain a fused representation, which is then input into a classifier to achieve adaptive weighting of multi-view features and platform classification output.

[0270] In this process, step S5.1 involves stitching together the projected views along the feature dimension to obtain a stitched representation, preserving the complete feature information of each view. Step S5.2 inputs the stitched representation into a content gating network, processes it through a fully connected layer and a sigmoid activation function, and obtains the content gating score for each view, quantifying the feature contribution of each view. Step S5.3 uses transport reliability as a reliability coefficient to perform multiplicative calibration on the content gating score, obtaining dual-feedback gating weights, and integrating the discriminative feedback from the transmission layer into the gating mechanism. Step S5.4 uses the dual-feedback gating weights to perform a weighted summation on each projected view, obtaining a fused representation, so that views with strong discriminative ability receive higher weights. Step S5.5 inputs the fused representation into a classifier, processes it through a fully connected layer and a softmax activation function, obtains the platform prediction result, and outputs a probabilistic platform classification.

[0271] Step S6: The platform prediction results, transportation matrix, and dual feedback gating weights are used to jointly calculate the loss and perform gradient backpropagation. The platform view prototype is then updated using exponential moving average.

[0272] Furthermore, step S6 specifically includes the following steps:

[0273] Step S6.1: Calculate the cross-entropy classification loss by comparing the platform prediction results with the actual platform labels.

[0274] Preferably, the core of this step is to quantify the classification prediction bias by calculating the cross-entropy classification loss between the platform prediction results and the real platform labels, thus providing a classification supervision signal for the joint loss.

[0275] Among them, for the cross-entropy classification loss, the sample The platform prediction results are a probability distribution. The real platform label is One-hot encoding Cross-entropy classification loss The calculation formula is:

[0276] .

[0277] in, Cross-entropy classification loss, For the sample One-hot encoding of real platform tags The corresponding components, For the sample In the platform prediction results, the platform The corresponding probability value, This refers to the batch sample size. This refers to the number of platforms.

[0278] Preferably, in the calculation of cross-entropy classification loss, the cross-entropy classification loss is... Item Plus prevent The data type of the loss value is Floating-point numbers.

[0279] For example, in a certain calculation, batch Number of samples, number of platforms The predicted probability of a sample on the PX4 platform Authentic Labels The cross-entropy of this sample ,all After averaging the samples The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-021.

[0280] Step S6.2: Calculate the prototype comparison loss by comparing the soft assignment probability in the transportation matrix with the real platform label.

[0281] Preferably, the core of this step is to constrain the prototype allocation direction by calculating the prototype comparison loss by comparing the soft allocation probability in the transportation matrix with the real platform label, thereby constraining the allocation direction of each platform prototype to samples to be consistent with the real label.

[0282] Among them, for the prototype contrast loss, the sample In view The sum of the soft assignment probabilities of the sub-prototypes of the correct platform will be used. The sum of the soft assignment probabilities of the sub-prototypes of the faulty platform Constructing a comparison, prototype comparison loss The calculation formula is:

[0283] .

[0284] in, For prototype comparison loss, For the sample In view The sum of soft assignment probabilities of being assigned to the correct platform prototype. For elements of the soft-assignment probability matrix, For the sample Authentic platform labels The number of sub-prototypes for each platform, This refers to the batch sample size. For the number of views, It is a numerically stable term.

[0285] Preferably, the prototype contrast loss is averaged over all views, and the data type of the loss value is... Floating-point numbers.

[0286] For example, in a certain calculation, the sum of the correct platform soft assignment probabilities for a sample on the PX4 platform under the lexical view. Under semantic view In the structural view Average prototype contrast loss of three views ,all After averaging the samples The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-022.

[0287] Step S6.3: Calculate the gating consistency loss by combining the content gating score in the dual feedback gating weights with the transportation reliability.

[0288] Preferably, the core of this step is to constrain the consistency between the gating weight and the transmission discrimination feedback. By calculating the gating consistency loss between the content gating score in the dual feedback gating weight and the transportation reliability, the allocation direction of the gating weight is constrained to be consistent with the discrimination ranking of the transportation reliability.

[0289] Among them, for gating consistency loss, content gating score Reflects the characteristic contribution of each view and transportation reliability Reflecting the transmission discrimination quality of each view, the ranking of both should be consistent; that is, views with higher discrimination quality should have higher gating scores, resulting in gating consistency loss. Using mean square error form:

[0290] .

[0291] in, For gating consistency loss, For sample i in view The normalized content gating score is calculated by dividing the sample by the normalized denominator, which is the maximum value of the content gating scores of the three views. For view The normalized transport reliability is calculated, with the normalized denominator being the maximum value of the transport reliability of the three views for the current batch. This refers to the batch sample size. This represents the number of views.

[0292] Preferably, the gating consistency loss normalization process is performed independently within each batch, and the loss value data type is... Floating-point numbers.

[0293] For example, the normalized content gating score of a sample on the PX4 platform in a certain calculation. , , Normalized transport reliability , , Gating consistency loss ,all After averaging the samples The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-023.

[0294] Step S6.4: The cross-entropy classification loss, prototype comparison loss, and gating consistency loss are weighted and summed to obtain the joint loss.

[0295] Preferably, the core of this step is to complete the unified metric for multi-objective optimization. By weighted summation of the three types of losses, a joint loss is obtained, thereby achieving collaborative optimization of classification supervision, prototype constraints, and gating consistency.

[0296] Specifically, for the joint loss, the cross-entropy classification loss is used. Prototype contrast loss Gating consistency loss The weighted summation based on their respective weights yields the joint loss. The calculation formula is:

[0297] .

[0298] in, For joint losses, The weights for the cross-entropy classification loss are... Compare the prototype with the loss weights. The sum of the weights of the three types of losses does not need to be the weight of the gating consistency loss. Each weight independently controls the optimization intensity of the corresponding loss.

[0299] Preferably, the cross-entropy classification loss weights Prototype comparison loss weights Gating consistency loss weight The data type of joint loss is Floating-point numbers.

[0300] For example, in a certain calculation , , Joint losses The corresponding timestamp record is YYYY-MM-DD-HH:MM:SS-024.

[0301] Step S6.5: Perform gradient backpropagation on the joint loss to update the parameters of each projection network, content gating network and classifier, and update the platform view prototype by exponential moving average.

[0302] Preferably, the core of this step is to complete the collaborative iteration of model parameters and platform view prototype. The parameters of each projection network, content gating network and classifier are updated by backpropagating the joint loss through gradients, and the platform view prototype is updated by exponential moving average, thereby achieving collaborative optimization of model parameters and prototype.

[0303] Specifically, for gradient backpropagation, the gradients of all trainable parameters are calculated for the joint loss; all trainable parameters include the parameters of each projection network and the parameters of the content-gated network. and classifier parameters The Adam optimizer is used for updating, and the parameter update formula is:

[0304] .

[0305] in, For all trainable parameters after the t-th step update, For learning rate, and These are the bias-corrected first-order moment estimates and second-order moment estimates of Adam, respectively. This is a numerically stable term located outside the square root.

[0306] Specifically, for the exponential moving average update of the platform view prototype, the prototype update is performed via exponential moving average instead of gradient backpropagation. The EMA update formula is:

[0307] .

[0308] in, For the platform In view The next The prototype This represents the EMA decay factor. The average value of the current batch of prototypes. Calculated using correct platform samples weighted according to the soft-assignment probability Q. To prevent numerically stable terms from being divided by zero, the atomic prototype remains unchanged when the corresponding denominator is zero.

[0309]

[0310] Preferably, the Adam optimizer learning rate First-order moment attenuation coefficient Second-order moment attenuation coefficient Numerical stability term EMA attenuation coefficient Gradient clipping threshold .

[0311] For example, in a certain update, the joint loss After gradient backpropagation, the parameter update order of each projection network is approximately [missing information]. The classifier parameter update order of magnitude is approximately The PX4 platform under the lexical view The current batch average of individual prototypes Compared with the original prototype The EMA update results are ,all Each platform view prototype synchronously performs EMA updates, with the corresponding timestamp record being YYYY-MM-DD-HH:MM:SS-025.

[0312] Beneficial effects of steps S6.1 to S6.5:

[0313] This series of steps involves jointly calculating the loss using the platform prediction results, transportation matrix, and dual-feedback gating weights, and then performing gradient backpropagation. The platform view prototype is updated using exponential moving averages, enabling collaborative optimization and continuous iteration of model parameters and the prototype.

[0314] Specifically, step S6.1 calculates the cross-entropy classification loss by comparing the platform prediction results with the real platform labels to quantify the deviation in classification prediction; step S6.2 calculates the prototype contrast loss by comparing the soft assignment probability in the transportation matrix with the real platform labels to constrain the direction of prototype sample allocation; step S6.3 calculates the gating consistency loss by comparing the content gating score in the dual feedback gating weights with the transportation reliability to constrain the consistency between the gating weights and the transmission discrimination feedback; step S6.4 calculates the joint loss by weighted summation of the cross-entropy classification loss, prototype contrast loss, and gating consistency loss to achieve a unified metric for multi-objective optimization; and step S6.5 updates the parameters of each projection network, content gating network, and classifier by gradient backpropagation on the joint loss, and updates the platform view prototype by exponential moving average to achieve coordinated iteration of model parameters and prototype.

[0315] In summary, the overall beneficial effects of steps S1 to S6 in this embodiment are as follows:

[0316] This method addresses the limitation of cross-platform recognition accuracy caused by the inability of a single view feature to fully characterize the multi-dimensional attributes of a function. It employs character-level lexical views, code semantic views, and lightweight structural views. Figure 3 The view joint representation function solves the soft allocation probability and calculates the transport reliability through entropy regularization optimal transmission. It uses dual feedback gating weights to weight and fuse the projected views, thereby achieving adaptive integration of multi-view features and iterative optimization of the platform prototype, and improving the recognition accuracy of the function-level platform.

[0317] In this process, step S1 constructs a training dataset through syntax parsing and hierarchical partitioning to ensure sample balance; step S2 constructs three views and projects them onto a shared space to eliminate the semantic gap of a single view; step S3 constructs a cost matrix based on the distance between the projected representation and the platform view prototype to provide a quantification basis for optimal transmission; step S4 solves the soft assignment probability and calculates the transportation reliability through entropy regularization of optimal transmission to quantify the discriminative ability of each view; step S5 calibrates the content gating score with the transportation reliability to obtain dual feedback gating weights, and weighted fusion to obtain a fused representation, realizing adaptive weighting of the view; step S6 performs gradient backpropagation in conjunction with three types of losses and updates the platform view prototype through exponential moving average to achieve collaborative optimization of model parameters and prototype.

[0318] like Figure 2 As shown, this embodiment provides an example of a function-level recognition system for open-source UAV flight control software. In this embodiment, the function-level recognition system is applied to the function-level recognition method as described in the above embodiment.

[0319] Specifically, the function-level recognition system includes a training dataset acquisition module 1, a view projection representation acquisition module 2, a cost matrix acquisition module 3, a transportation reliability calculation module 4, a platform prediction result acquisition module 5, and a platform view prototype update module 6, which are connected electrically or through communication.

[0320] The training dataset acquisition module 1 collects fixed-version source code from at least two open-source UAV flight control software repositories. It extracts function definitions from the source files using a syntax parser, filters and removes duplicates, and then partitions the data according to platform labels to obtain the training dataset. The view projection representation acquisition module 2 constructs a character-level lexical view, a code semantic view, and a lightweight structure view for each function in the training dataset. It then inputs each view into the corresponding projection network and maps it to a shared space of the same dimension to obtain the projection representation of each view. The cost matrix acquisition module 3 initializes a platform view prototype for each platform under each view and uses the distance between the projection representation and the platform view prototype as the cost to obtain the cost. The transportation reliability calculation module 4 uses the cost matrix as input to solve for the transportation matrix using entropy regularization optimal transmission, and normalizes the transportation matrix by sample rows to obtain soft assignment probabilities, and calculates the transportation reliability of each view; the platform prediction result acquisition module 5 uses the stitched representation of each projected view as input to the content gating network to obtain the content gating score, calibrates the transportation reliability against the content gating score to obtain the dual feedback gating weights, and then weights and fuses them to obtain the fused representation, and inputs the fused representation into the classifier to obtain the platform prediction result; the platform view prototype update module 6 uses the platform prediction result, transportation matrix, and dual feedback gating weights to jointly calculate the loss and perform gradient backpropagation, and updates the platform view prototype through exponential moving average.

[0321] like Figure 3 As shown, the electronic device 7 includes a processor 71 and a memory 72 coupled to the processor 71.

[0322] The memory 72 stores program instructions for implementing the function-level recognition method of the open-source UAV flight control software of any of the above embodiments.

[0323] The processor 71 is used to execute program instructions stored in the memory 72 to perform function-level recognition of the open-source UAV flight control software.

[0324] The processor 71 can also be referred to as a CPU (Central Processing Unit). The processor 71 may be an integrated circuit chip with signal processing capabilities. The processor 71 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor.

[0325] Furthermore, Figure 4 This is a schematic diagram of the structure of a storage medium according to an embodiment of this application. See also: Figure 4 The storage medium 8 in this embodiment stores program instructions 81 capable of implementing all the above methods. These program instructions 81 can be stored in the storage medium as a software product, including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods in each embodiment of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, or terminal devices such as computers, servers, mobile phones, and tablets.

[0326] In the several embodiments provided in this application, it should be understood that the disclosed systems, methods, and approaches can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For instance, the function-level identification of the open-source UAV flight control software of a unit is only one logical function of the open-source UAV flight control software. In actual implementation, there may be other function-level identification methods for the open-source UAV flight control software. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of the system or unit may be electrical, mechanical, signal, or other forms.

[0327] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units. The above are merely embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made based on the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.< / tag>

Claims

1. A function-level recognition method for open-source UAV flight control software, characterized in that, The function-level recognition method includes: Step S1: Collect fixed version source code from at least two open source UAV flight control software repositories, extract function definitions from the source files using a syntax parser, filter and remove duplicates, and then divide the data into layers according to platform tags to obtain the training dataset. Step S2: For each function in the training dataset, construct a character-level lexical view, a code semantic view, and a lightweight structure view, and input each view into the corresponding projection network and map it to a shared space of the same dimension to obtain the projection representation of each view; Step S3: Initialize the platform view prototype for each platform under each view, and use the distance between the projection representation and the platform view prototype as the cost to obtain the cost matrix; Step S4: Use the cost matrix as input to solve for the transport matrix, and normalize the transport matrix by sample rows to obtain the soft allocation probability, and calculate the transport reliability of each view. Step S5: Input the stitched representation of each projected view into the content gating network to obtain the content gating score, calibrate the transportation reliability to the content gating score to obtain the dual feedback gating weight, and then perform weighted fusion to obtain the fused representation. Input the fused representation into the classifier to obtain the platform prediction result. Step S6: The platform prediction result, the transportation matrix, and the dual feedback gating weights are used to jointly calculate the loss and perform gradient backpropagation. The platform view prototype is then updated using exponential moving average. Step S6 involves jointly calculating the loss using the platform prediction result, the transportation matrix, and the dual-feedback gating weights, performing gradient backpropagation, and updating the platform view prototype using exponential moving average, including: Step S6.1: Calculate the cross-entropy classification loss by comparing the platform prediction results with the actual platform labels; Step S6.2: Compare the soft allocation probability in the transportation matrix with the loss calculated from the prototype of the real platform label; Step S6.3: Calculate the gating consistency loss by combining the content gating score in the dual feedback gating weights with the transportation reliability. Step S6.4: The cross-entropy classification loss, the prototype contrast loss, and the gating consistency loss are weighted and summed to obtain the joint loss; Step S6.5: Perform gradient backpropagation on the joint loss to update the parameters of each projection network, content gating network and classifier, and update the platform view prototype by exponential moving average.

2. The function-level identification method according to claim 1, characterized in that, Step S1: Collect fixed-version source code from at least two open-source UAV flight control software repositories. Extract function definitions from the source files using a syntax parser. After filtering and deduplication, divide the data into layers according to platform tags to obtain the training dataset, including: Step S1.1: Collect fixed version source code from at least two open-source UAV flight control software repositories, record the platform tag and version identifier of each repository, and integrate them to obtain a set of source code files; Step S1.2: Traverse the source files in the source code file set using a syntax parser to extract function names, parameter lists, and function bodies, and integrate them to obtain the original function set; Step S1.3: Delete functions with fewer than a preset threshold and duplicate functions from the original function set to obtain a candidate function set; Step S1.4: Count the number of samples for each platform label in the candidate function set, and divide them proportionally to obtain the training dataset.

3. The function-level identification method according to claim 1, characterized in that, Step S2: For each function in the training dataset, construct a character-level lexical view, a code semantic view, and a lightweight structure view, and input each view into the corresponding projection network and map it to a shared space of the same dimension to obtain the projected representation of each view, including: Step S2.1: Perform character-level word segmentation on each function in the training dataset to extract character n-gram frequency features and construct a term frequency-inverse document frequency vector to obtain a character-level lexical view; Step S2.2: Input each function in the training dataset into the pre-trained code semantic encoder to extract the last hidden state and perform mean pooling to obtain the code semantic view; Step S2.3: Extract structural statistics such as the number of control flow edges, cyclomatic complexity, number of parameters, and maximum nesting depth for each function in the training dataset, and integrate them to obtain a lightweight structural view; Step S2.4: Input the character-level lexical view, the code semantic view, and the lightweight structure view into the corresponding projection network and map them to a shared space of the same dimension to obtain the projection representation of each view.

4. The function-level identification method according to claim 1, characterized in that, Step S3: Initialize a platform view prototype for each platform under each view, and use the distance between the projection representation and the platform view prototype as the cost to obtain a cost matrix, including: Step S3.1: For each platform under each view, randomly select several samples from the projection representation as initial prototypes to obtain the platform view prototype; Step S3.2: Calculate the cosine distance between the projection representation of each sample and each platform view prototype; Step S3.3: Arrange the cosine distances according to the sample index and the platform prototype index to obtain the cost matrix.

5. The function-level identification method according to claim 1, characterized in that, Step S4 involves using the cost matrix as input to solve for the transport matrix using entropy-normalized optimal transport, normalizing the transport matrix by sample rows to obtain soft allocation probabilities, and calculating the transport reliability of each view, including: Step S4.1: The cost matrix is ​​used as the input for entropy regularized optimal transport. The transport matrix is ​​obtained by Sinkhorn iteration with the batch sample distribution and platform prototype distribution as marginal constraints. Step S4.2: Normalize the transportation matrix by sample rows to obtain the soft assignment probability of each sample to each platform prototype; Step S4.3: Calculate the sum of the soft assignment probabilities of each sample being assigned to all sub-prototypes of the correct platform under each view, and calculate the average soft assignment entropy of each view. Step S4.4: Combine the average transportation cost of each view with the average soft allocation entropy to calculate the transportation reliability of each view.

6. The function-level identification method according to claim 1, characterized in that, Step S5: Input the stitched representation of each projected view into the content gating network to obtain a content gating score; calibrate the transport reliability against the content gating score to obtain dual-feedback gating weights; then weight and fuse them to obtain a fused representation; input the fused representation into a classifier to obtain the platform prediction result, including: Step S5.1: Stitch the projected views along the feature dimensions to obtain the stitched representation; Step S5.2: The spliced ​​representation of the input content gating network is processed by a fully connected layer and a Sigmoid activation function to obtain the content gating score of each view; Step S5.3: Use the transportation reliability as a reliability coefficient to perform multiplicative calibration on the content gating score to obtain the dual feedback gating weight; Step S5.4: The projected views are weighted and summed using the dual-feedback gating weights to obtain the fused representation; Step S5.5: Input the fused representation into the classifier, process it through a fully connected layer and a Softmax activation function to obtain the platform prediction result.

7. A function-level recognition system for open-source UAV flight control software, wherein the function-level recognition system is applied to the function-level recognition method as described in any one of claims 1 to 6, characterized in that, The function-level recognition system includes: The training dataset acquisition module is used to collect fixed versions of source code from at least two open-source drone flight control software repositories. The function definitions are extracted from the source files by a syntax parser, filtered and deduplicated, and then divided into layers according to platform tags to obtain the training dataset. The view projection representation acquisition module is used to construct a character-level lexical view, a code semantic view, and a lightweight structure view for each function in the training dataset, and input each view into the corresponding projection network and map it to a shared space of the same dimension to obtain the projection representation of each view; The cost matrix acquisition module is used to initialize a platform view prototype for each platform under each view, and use the distance between the projection representation and the platform view prototype as the cost to obtain the cost matrix. The transportation reliability calculation module is used to solve for the transportation matrix by taking the cost matrix as input to the entropy regularized optimal transmission, and to normalize the transportation matrix by sample rows to obtain the soft allocation probability, and to calculate the transportation reliability of each view. The platform prediction result acquisition module is used to input the stitched representation of each projected view into the content gating network to obtain the content gating score, calibrate the transportation reliability to the content gating score to obtain the dual feedback gating weight, and then weight and fuse them to obtain the fused representation. The fused representation is then input into the classifier to obtain the platform prediction result. The platform view prototype update module is used to jointly calculate the loss by combining the platform prediction results, the transportation matrix, and the dual feedback gating weights, and perform gradient backpropagation, and update the platform view prototype by exponential moving average.

8. An electronic device, characterized in that, The method includes a processor and a memory coupled to the processor, the memory storing program instructions executable by the processor; when the processor executes the program instructions stored in the memory, it implements the function-level identification method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions that, when executed by a processor, enable the function-level identification method as described in any one of claims 1 to 6.