CN111881028A - Neural network automatic generation method based on model code syntactic analysis - Google Patents

Neural network automatic generation method based on model code syntactic analysis Download PDF

Info

Publication number
CN111881028A
CN111881028A CN202010712775.7A CN202010712775A CN111881028A CN 111881028 A CN111881028 A CN 111881028A CN 202010712775 A CN202010712775 A CN 202010712775A CN 111881028 A CN111881028 A CN 111881028A
Authority
CN
China
Prior art keywords
neural network
code
program
automatic generation
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010712775.7A
Other languages
Chinese (zh)
Inventor
陈振宇
刘佳玮
曹可凡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Muzhi Technology Co ltd
Original Assignee
Shenzhen Muzhi Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Muzhi Technology Co ltd filed Critical Shenzhen Muzhi Technology Co ltd
Priority to CN202010712775.7A priority Critical patent/CN111881028A/en
Publication of CN111881028A publication Critical patent/CN111881028A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology

Abstract

A neural network automatic generation method based on model code syntax analysis is characterized in that a syntax library is abstracted according to syntax structures of a neural network built under different frameworks, and a safety check mechanism is built to ensure the correctness of a code generation program; on the basis, corresponding code characteristics are fused, the use scene of the neural network is restored, and the usability of the code generation program is improved. In order to realize automatic generation under different technical frameworks and network structures, the automatic generation tool of the neural network is realized from coarse granularity, a single structure and individual frameworks to finer granularity, supports various models and does not depend on specific technical frameworks through continuous iteration.

Description

Neural network automatic generation method based on model code syntactic analysis
Technical Field
The invention belongs to the field of software testing, and particularly relates to deep learning compiler testing. According to the construction rule of the neural network model code, the automatic generation of the deep neural network is realized by analyzing the rule of the existing network code in the open source community.
Background
The development of hardware computing power and the acceptance in the industry enable artificial intelligence and deep learning to gradually deepen into more fields, and the artificial intelligence and deep learning have achieved technical achievements particularly in the fields of medical diagnosis, automatic driving, face recognition and the like, and have started the popularization of products. In contrast, the underlying framework as a support for deep learning functions becomes a bottleneck limiting its further development. On the one hand, the reliability of these underlying frameworks is questionable, and tests for these frameworks are still being actively carried out; on the other hand, because the framework provides rich and easy-to-use API, the process of manufacturing wheels is reduced for developers, and the threshold of the developers is lowered. Meanwhile, the more detailed the division of the deep learning application, the fewer codes which can be shared under different scenes, and the process of repeatedly constructing the model code also becomes a limit for limiting the development of the deep learning application.
From the viewpoint of program development, the importance of compilers, one of the most commonly used system software, is self-evident, and research on testing techniques of compilers has been an important branch of the software testing field. Current testing for compilers has enabled research in some of the more common programming languages. Existing compiler test validation tools (such as SuperTest, CVSAC, etc.) mainly focus on the implementation of compiler on the consistency of language standards. Csmith is a random difference testing tool of a compiler, and mainly focuses on searching errors in the compiling intermediate process of the compiler. Csmith randomly generates test cases using a custom grammar subset. It takes into account a most basic syntax subset and is implemented in a hard-coded manner. To date, it has found hundreds of errors in GCC and LLVM and helps improve the quality of the most widely used C compilers.
The traditional approach to neural network architecture is: parameters of the network architecture and corresponding training are traversed until the task performance reaches a point of reduced revenue. This approach faces a number of problems. One is the problem of architecture fixation, most of which are based on the back propagation method to train the network weight, not the architecture. They only use gradient information in the weight space of the neural network, and the neural network architecture in the whole training process is fixed. Therefore, such an approach does not lead to a better network architecture. Secondly, the methods all need a long lifting process, and searching for a proper neural network architecture by a trial and error method is very inefficient. This problem becomes more severe as the network deepens, containing millions of parameters. Even the fastest GPUs take tens of hours each time a deep neural network is tried. It is to be appreciated that GPUs are currently the mainstay of neural network training. Even with sufficient computing power and researchers, finding an excellent architecture suitable for certain applications can take years, such as the image domain, a revolution from AlexNet to VGG, google net, ResNet. Thirdly, a great deal of redundancy is caused, which results in that most of the parameters of the neural network are excessive. Even the most well-known networks in image classification tasks (e.g., LeNets, AlexNet, VGG) face a large amount of storage and computational redundancy.
Learning and performing of language or grammar is a typical mental activity of human beings, and various models of these processes using neural networks have been proposed.
Currently, the academic community has performed a series of work on testing of the deep learning framework. csmith is a work of automatically generating a program by a grammar library based on C language grammar, and the work ensures the usability of the program by constructing grammar subsets and assisting safety check, and is currently focused on the test of a C compiler. CRADLE is aimed at capturing bugs under a potential deep learning framework through differential testing and locating layers where bugs occur through change rates, however, the models used in this approach are limited. The AUDEE is a new work, random testing is carried out by summarizing parameter value ranges and metamorphic relations of common APIs (application programming interfaces), but the automatically generated model only realizes the random parameter level. Therefore, the invention realizes automatic generation of the neural network by analyzing the neural network and constructing the code grammar based on the existing research results, and can be further used for testing the deep learning compiler.
Disclosure of Invention
The invention aims to solve the problems that: the C programming program is constructed by using the grammar structure of the programming language and is obtained on the test of the C compiler
With great success, but there is no new progress in the deep learning field. The invention can realize the random generation of the model code from the code level, is used for the random test of a deep learning framework and a bottom compiler, and solves the problem that the random test in the deep learning field lacks model data.
The technical scheme of the invention is as follows: neural network automatic generation method based on model code syntactic analysis
The method is characterized in that an operable network model can be generated according to the grammatical rules of the neural network codes. The generation method comprises the following 6 steps:
1. the present invention randomly selects an allowed generation for the current program point from its syntax. For selection it consults the probabilities
Table and filter functions specific to the current point: there is one table, filter pair for statements, another for expressions, and so on. The table assigns a probability to each alternative, where the sum of the probabilities is 1. After a code block is selected from the table and generated, the invention begins performing a filter operation that determines whether the selection is acceptable in the current situation.
2. If an object (e.g., variable or function) is required for the selected code block, the generator will randomly select an appropriate defined object or define a new object. Essentially, the present invention dynamically builds a probability table for potential targets and includes a create option. Thus, function and variable definitions are dynamically created when the present invention decides to refer to them.
3. If the selected code block allows the generator to select one type, the invention will select one at random. Depending on the current context, the selection may be limited (e.g., when generating operands for integer-type expressions) or unlimited (e.g., when generating random variables and generating parameter types for new functions.) random selection is guided by syntax, probability tables, and filters that have been described.
4. If the selected code block is a non-terminating code block, the generator recurses. The generator calls a function to generate a NAND termination code
The block corresponds to a program fragment. More generally, the present invention recursively compounds each non-terminating element (e.g., for each subcomponent) in the current block of code, or each parameter in a function call.
5. The present invention performs a set of dataflow transfer functions. It passes point-to-fact from the local environment to the transfer function, resulting in a new set of point-to-fact. The present invention updates the local environment with these facts.
6. The present invention performs a set of security checks. If the check is successful, the new code fragment is submitted to the generated program. Otherwise, the fragment will be deleted and any changes to the local environment rolled back.
When the present invention creates a call to a new function (the subject of which does not yet exist), the generation of the current function will be suspended until
Until the new function is completed. Thus, the present invention completes when the top-level function has been fully generated. At that time, it gracefully prints all randomly generated definitions in the proper order: type, global variable, prototype, and function. Finally, the present invention outputs one primary function. And calling a top-level randomly generated function by the main function, calculating the check sum of the non-pointer global variable, printing the check sum, and exiting.
The invention is characterized in that:
1. the method for generating the model code by using the automatic program is firstly proposed in the field of deep learning test.
2. The syntax analysis technique is applied to the testing of the deep learning framework for the first time.
3. The testing of the deep learning framework is extended to the testing for all API interfaces for the first time.
Drawings
Fig. 1 is a general flow chart of the implementation of the present invention.
Fig. 2 is a flowchart of API call statement generation.
Fig. 3 is a flow chart of the flow control statement generation.
Fig. 4 is a security check flow chart.
Detailed Description
The embodiments of the present invention are described below with reference to specific examples, and other advantages and effects of the present invention will be readily apparent to those skilled in the art from the disclosure of the present specification.
The method implements automatic generation of the neural network model codes through grammar, mainly adopts grammar rule check, and relates to specific key technologies such as a Deep Neural Network (DNN), a deep Convolutional Neural Network (CNN), a Recurrent Neural Network (RNN), an abstract syntax tree technology and the like.
1. Generating environmental controls
The invention maintains a global context, i.e. type, global variable and function, with the highest level of definition. The global environment will be extended when new entity types are defined during program generation. The present invention also uses three main pieces of information to maintain the local environment in order to save information about current program spawn points. First, the local environment describes the current call chain, supporting context-dependent pointer analysis. Second, it contains (1) the start of the current function, (2) the start of the current statement and (3) effect information for objects that may have been read or written since the previous sequence point. In addition, the local environment contains the pointing fact of all in-range pointers.
2. Parameter generation mechanism
The invention first creates a set of structure type declarations at random. For each member, it randomly decides the number of members and the type of each member. The type of member may be an (possibly qualified) integer type, a bit field, or a previously generated structure type.
After the preliminary step of generating the type definition, the present invention begins generating python program code. The invention starts from the program entry and generates the program from top to bottom.
3. Filter mechanism
The filter enforces basic semantic restrictions (e.g., continue can only appear in a loop), user-controllable restrictions (e.g., maximum statement depth and number of functions), and other user-controllable options. If the filter rejects the selected code block, the invention simply loops back to select from the table until the filter is successful.
4. Program syntax specification
The specification of the program generated by the present invention is governed by the syntax of the python3 language. A program is a collection of types, variables, and function definitions. The method body is modeled as a block; a block contains a statement list and a statement list; statements are expressions, control flow constructs, assignments, or blocks. The internal implementation of different blocks introduces code properties that ensure that the generator meets the properties of the programming language and the programming framework. The present invention also utilizes grammars to generate other programs representing programming characteristics. The syntax is implemented by a set of manually coded python classes. .
5. Program characteristic control
The dynamically realized constructed code should contain more language characteristics so as to improve the quality of the constructed code to the maximum extent. Any "language" is a combination of various "linguistic characteristics". In addition to the generic language properties that programming languages have themselves, there is also a need to consider the "specific" properties that accompany a framework or model structure. The expression capability of the program can be improved by utilizing rich language characteristics, and the practical value of the constructed code is further enhanced. The research abstracts the code characteristics based on the programming language and the 'special' characteristics of the accompanying framework or model structure by analyzing the construction process of the neural network, and realizes the usability of automatically generating programs.
In the embodiment, syntactic structure analysis is carried out according to the construction code of the neural network, the implementation modes under different frames are investigated, the automatic selection and safety check process of the network construction code segment is realized, and in the process, the language characteristics are restored as much as possible, so that the generated model is close to the existing programming habit, and finally, the automatic construction of the neural network is completed.

Claims (5)

1. A neural network automatic generation method based on model code grammar analysis is characterized in that a global environment with highest level definition is maintained, a probability table and a filter function specific to a current point are consulted, the expression capability of a program can be improved by utilizing abundant language characteristics, the practical value of a constructed code is further enhanced, and a necessary grammar library in an automatic generation process is realized by a group of manually coded python classes.
2. Maintaining a global environment with a highest level of definition as described in claim 1, wherein: the global environment will be extended when new entity types are defined during program generation. The present invention also uses three main pieces of information to maintain the local environment in order to save information about current program spawn points. First, the local environment describes the current call chain, supporting context-dependent pointer analysis. Second, it contains (1) the start of the current function, (2) the start of the current statement and (3) effect information for objects that may have been read or written since the previous sequence point. In addition, the local environment contains the pointing fact of all in-range pointers.
3. The lookup probability table and current point specific filter function of claim 1 wherein: the filter enforces basic semantic restrictions (e.g., continue can only appear in a loop), user-controllable restrictions (e.g., maximum statement depth and number of functions), and other user-controllable options. If the filter rejects the selected code block, the invention simply loops back to select from the table until the filter is successful.
4. The use of rich language features to increase the expressive power of a program as claimed in claim 1, wherein: by analyzing the building process of the neural network, code characteristics based on a programming language and 'special' characteristics accompanying a framework or a model structure are abstracted, and the usability of automatically generating the program is realized.
5. The grammar library necessary for implementing the automatic generation process by a set of manually coded python classes as described in claim 1, wherein: the method body is modeled as a block; a block contains a statement list and a statement list; statements are expressions, control flow constructs, assignments, or blocks. The internal implementation of different blocks introduces code properties that ensure that the generator meets the properties of the programming language and the programming framework. The present invention also utilizes grammars to generate other programs representing programming characteristics.
CN202010712775.7A 2020-07-23 2020-07-23 Neural network automatic generation method based on model code syntactic analysis Pending CN111881028A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010712775.7A CN111881028A (en) 2020-07-23 2020-07-23 Neural network automatic generation method based on model code syntactic analysis

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010712775.7A CN111881028A (en) 2020-07-23 2020-07-23 Neural network automatic generation method based on model code syntactic analysis

Publications (1)

Publication Number Publication Date
CN111881028A true CN111881028A (en) 2020-11-03

Family

ID=73155810

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010712775.7A Pending CN111881028A (en) 2020-07-23 2020-07-23 Neural network automatic generation method based on model code syntactic analysis

Country Status (1)

Country Link
CN (1) CN111881028A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704382A (en) * 2017-09-07 2018-02-16 北京信息科技大学 Towards Python function call path generating method and system
CN108345457A (en) * 2018-01-24 2018-07-31 上海交通大学 A method of to program source code automatic generation function descriptive notes
CN110232280A (en) * 2019-06-20 2019-09-13 北京理工大学 A kind of software security flaw detection method based on tree construction convolutional neural networks
CN110362597A (en) * 2019-06-28 2019-10-22 华为技术有限公司 A kind of structured query language SQL injection detection method and device
CN110502361A (en) * 2019-08-29 2019-11-26 扬州大学 Fine granularity defect positioning method towards bug report

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704382A (en) * 2017-09-07 2018-02-16 北京信息科技大学 Towards Python function call path generating method and system
CN108345457A (en) * 2018-01-24 2018-07-31 上海交通大学 A method of to program source code automatic generation function descriptive notes
CN110232280A (en) * 2019-06-20 2019-09-13 北京理工大学 A kind of software security flaw detection method based on tree construction convolutional neural networks
CN110362597A (en) * 2019-06-28 2019-10-22 华为技术有限公司 A kind of structured query language SQL injection detection method and device
CN110502361A (en) * 2019-08-29 2019-11-26 扬州大学 Fine granularity defect positioning method towards bug report

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
HANBINGTAO: "零基础入门深度学习(7) - 递归神经网络", 《HTTPS://ZYBULUO.COM/HANBINGTAO/NOTE/626300》 *

Similar Documents

Publication Publication Date Title
CN108388425B (en) Method for automatically completing codes based on LSTM
Balzer Transformational implementation: An example
KR101224813B1 (en) Relationship modeling
CN115659281B (en) Method and device for fusing adaptive acceleration operators
Chandlee et al. Input strictly local opaque maps
CN114860893B (en) Intelligent decision-making method and device based on multi-mode data fusion and reinforcement learning
CN111666071B (en) Method and system for resisting network transplantation and optimization based on target many-core
US11513774B2 (en) Multi-lingual code generation with zero-shot inference
CN113031966A (en) Deep learning compilation optimization method for intelligently selecting compilation acceleration library
Lu et al. Program classification using gated graph attention neural network for online programming service
CN113885845B (en) Calculation map generation method, system, equipment and medium of deep learning compiler
CN111125996B (en) Method for realizing instruction set based on bidirectional constraint tree of pseudo-random excitation generator
CN111881028A (en) Neural network automatic generation method based on model code syntactic analysis
Cummins et al. Deep data flow analysis
Jiang et al. Constraint reasoning embedded structured prediction
CN112633516B (en) Performance prediction and machine learning compiling optimization method and device
CN115270795A (en) Small sample learning-based named entity recognition technology in environmental assessment field
Lai et al. Defining and verifying behaviour of domain specific language with fUML
Williams et al. Search-based model driven engineering
CN112015426A (en) Code management method, device and equipment
Simov et al. Word embeddings improvement via echo state networks
CN117421414B (en) Design method of RPA intelligent interactive system based on AIGC
CN116225452A (en) Multi-level intermediate code-based graph neural network compiling optimization method
CN112925564B (en) Method and device for cleaning redundant import class of source code
CN114595340A (en) Knowledge graph path reasoning method and system based on distributed database system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20201103