CN117236407A - Model structure optimization method and device, electronic equipment and storage medium - Google Patents

Model structure optimization method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117236407A
CN117236407A CN202311183241.XA CN202311183241A CN117236407A CN 117236407 A CN117236407 A CN 117236407A CN 202311183241 A CN202311183241 A CN 202311183241A CN 117236407 A CN117236407 A CN 117236407A
Authority
CN
China
Prior art keywords
node
output
child
target
taking
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
CN202311183241.XA
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.)
ARM Technology China Co Ltd
Original Assignee
ARM Technology China 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 ARM Technology China Co Ltd filed Critical ARM Technology China Co Ltd
Priority to CN202311183241.XA priority Critical patent/CN117236407A/en
Publication of CN117236407A publication Critical patent/CN117236407A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02TCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
    • Y02T10/00Road transport of goods or passengers
    • Y02T10/10Internal combustion engine [ICE] based vehicles
    • Y02T10/40Engine management systems

Landscapes

  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The embodiment of the application provides a model structure optimization method, a device, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the following steps: acquiring a node structure of a target model, and determining a target optimization structure in the node structure; determining an original output node of each child node respectively, adding a first node newly, taking the first node as a new output node of at least two child nodes, and taking the first node as an input node of the original output node; and taking the target optimization structure and the first node as a structure to be replaced, and adopting a second node to replace the structure to be replaced to obtain an optimized node structure. By creating a new node after a plurality of output nodes, the optimization structure of the model is adjusted to be in a single-node output form, so that the structure of the multi-node output can be optimized, the limitation of an optimization matching algorithm is broken, the storage space occupied by the neural network model can be greatly reduced, and the calculation efficiency of the neural network model can be greatly improved.

Description

Model structure optimization method and device, electronic equipment and storage medium
Technical Field
The application relates to the technical field of computers, in particular to a model structure method, a device, electronic equipment and a storage medium.
Background
The neural network basic principle is a calculation model for simulating the functions of the human brain nervous system, the model can be represented by a calculation graph, the calculation graph is composed of a plurality of nodes, the nodes are connected through edges, the nodes form a plurality of layers, the input of each layer of nodes is the output of the node of the upper layer, and the output of the final output layer is the result of the neural network.
For a neural network model, the number of nodes and the number of layers formed by the nodes can reflect the complexity of the model, and the complexity can reflect the space occupied by the model and the calculation efficiency, in general, the smaller the number of the nodes or the smaller the number of the layers, the smaller the occupied space of the model and the higher the calculation efficiency. When solving the complex problem, the model designed by the model designer is often complex, possibly with thousands of nodes, and at this time, the storage space occupied by the model is larger and the calculation efficiency is lower, so that a method is needed to optimize the structure of the complex neural network model to solve the problem.
In the scheme in the prior art, the structure of the neural network model is generally optimized through an optimization matching algorithm, but the optimization matching algorithm can only optimize the node structure with a single output node, but cannot optimize the node structure with a plurality of output nodes, as shown in fig. 1, the node structure A-B in the first leftmost node structure in fig. 1 is a target optimization structure, and because the input node in the target optimization structure is only the node A and the output node is only the node B, the structure can be directly replaced by the node N (namely, optimized to be a second node structure) through the optimization matching algorithm; the third node structure in fig. 1 is a target optimization structure, and the target optimization structure contains two output nodes B0 and B1, so that the target optimization structure cannot be directly optimized into a fourth node structure by adopting an optimization matching algorithm.
In practical operation, the neural network model is often structured in a form of multiple output points, so that the optimization capacity of the prior art scheme is very limited, and the optimized model still has the problems.
Disclosure of Invention
The application aims to at least solve one of the technical defects, and the technical scheme provided by the embodiment of the application is as follows:
In a first aspect, an embodiment of the present application provides a method for optimizing a model structure, including:
acquiring a node structure of a target model, and determining a target optimization structure in the node structure; the target optimization structure comprises a father node and at least two child nodes corresponding to the father node;
determining an original output node of each child node respectively, adding a first node newly, taking the first node as a new output node of at least two child nodes, and taking the first node as an input node of the original output node;
taking the target optimization structure and the first node as a structure to be replaced, and adopting a second node to replace the structure to be replaced to obtain an optimized node structure; wherein the execution algorithm of the second node is the same as the execution algorithm of the structure to be replaced.
In an optional embodiment of the present application, before the first node is newly added, the method specifically further includes:
determining a target dominant point in the node structure according to the target optimization structure; the target dominant point is a common node which is closest to each child node after the execution sequence in the node structure is in the target optimization structure and is in the process of traversing each child node simultaneously in the sequence reverse to the execution sequence;
The method for adding the first node specifically comprises the following steps:
and adding the first node based on the target dominant point.
In an alternative embodiment of the present application, the adding of the first node based on the target dominant point specifically includes:
traversing each node in sequence based on the execution sequence of each node in the node structure, acquiring a first sub-node if the execution sequence comprises a target optimization structure in the structure before the target dominant point, and adding a first node between the first sub-node and a first output node based on the node structure; the first child node is any node in all child nodes, and the first output node is an original output node of the first child node.
In an alternative embodiment of the present application, after the first node is the new output node of the at least two child nodes, the method specifically includes:
storing the output value of each second child node into the first node; the second child node is other nodes except the first child node in each child node;
for each output value, generating a key value pair for the output value and the corresponding second child node;
the method for using the first node as the input node of the original output node specifically comprises the following steps:
regarding a first output node, taking the first node as an input node of the first output node based on the corresponding relation between the first child node and the first output node;
For each second output node, determining a corresponding second child node based on the node structure, and taking the first node as an input node of the second output node according to the key value pair related to the second child node; the second output node is an original output node of the second child node.
In an optional embodiment of the application, after generating the key value pair related to the output value and the corresponding second child node, the method specifically further comprises:
storing each key value pair into a preset dictionary;
the input node using the first node as the second output node according to the key value pair related to the second child node specifically comprises:
and acquiring a key value pair related to the second child node from the preset dictionary, and taking the first node as an input node of the second output node according to the key value pair.
In an alternative embodiment of the present application, the input node using the first node as the second output node according to the key value pair specifically includes:
and acquiring a key value of the key value pair, and adjusting the input value of the second output node to a corresponding output value stored in the first node according to the key value.
In an alternative embodiment of the present application, the target optimization structure and the first node are used as a structure to be replaced, and the second node is used to replace the structure to be replaced, so as to obtain an optimized node structure, which specifically includes:
Taking a father node of the target optimization structure as a starting point of the structure to be replaced and taking the first node as an ending point of the structure to be replaced;
and replacing the structure to be replaced with the second node by an optimized matching algorithm based on the starting point and the ending point.
In a second aspect, an embodiment of the present application provides a model structure optimization apparatus, including:
the target optimization structure acquisition module is used for acquiring a node structure of the target model and determining a target optimization structure in the node structure; the target optimization structure comprises a father node and at least two child nodes corresponding to the father node;
the node generation module is used for respectively determining the original output node of each child node, adding a first node newly, taking the first node as a new output node of at least two child nodes, and taking the first node as an input node of the original output node;
the node structure optimization module is used for taking the target optimization structure and the first node as a structure to be replaced, and replacing the structure to be replaced by adopting a second node to obtain an optimized node structure; wherein the execution algorithm of the second node is the same as the execution algorithm of the structure to be replaced.
In an alternative embodiment of the present application, the apparatus further includes a target dominant point acquisition module, specifically configured to:
Determining a target dominant point in the node structure according to the target optimization structure; the target dominant point is a common node which is closest to each child node after the execution sequence in the node structure is in the target optimization structure and is in the process of traversing each child node simultaneously in the sequence reverse to the execution sequence;
the node generation module is specifically configured to:
and adding the first node based on the target dominant point.
In an alternative embodiment of the application, the node generating module is further configured to:
traversing each node in sequence based on the execution sequence of each node in the node structure, acquiring a first sub-node if the execution sequence comprises a target optimization structure in the structure before the target dominant point, and adding a first node between the first sub-node and a first output node based on the node structure; the first child node is any node in all child nodes, and the first output node is an original output node of the first child node.
In an optional embodiment of the application, the apparatus further comprises a key value pair generating module, specifically configured to:
storing the output value of each second child node into the first node; the second child node is other nodes except the first child node in each child node;
For each output value, generating a key value pair for the output value and the corresponding second child node;
the node generation module may also be configured to:
regarding a first output node, taking the first node as an input node of the first output node based on the corresponding relation between the first child node and the first output node;
for each second output node, determining a corresponding second child node based on the node structure, and taking the first node as an input node of the second output node according to the key value pair related to the second child node; the second output node is an original output node of the second child node.
In an alternative embodiment of the present application, the apparatus further includes a key value pair storage module, specifically configured to:
storing each key value pair into a preset dictionary;
the node generation module may also be configured to:
and acquiring a key value pair related to the second child node from the preset dictionary, and taking the first node as an input node of the second output node according to the key value pair.
In an alternative embodiment of the application, the node generating module may be further configured to:
and acquiring a key value of the key value pair, and adjusting the input value of the second output node to a corresponding output value stored in the first node according to the key value.
In an alternative embodiment of the present application, the node structure optimization module is specifically configured to:
taking a father node of the target optimization structure as a starting point of the structure to be replaced and taking the first node as an ending point of the structure to be replaced;
and replacing the structure to be replaced with the second node by an optimized matching algorithm based on the starting point and the ending point.
In a third aspect, an embodiment of the present application provides an electronic device including a memory, a processor, and a computer program stored on the memory;
the processor executes a computer program to implement the method provided in the first aspect embodiment or any alternative embodiment of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor implements the method provided in the embodiment of the first aspect or any of the alternative embodiments of the first aspect.
The technical scheme provided by the embodiment of the application has the beneficial effects that:
by creating a new node after a plurality of output nodes, the optimization structure of the model is adjusted to be in a single-node output form, so that the structure of the multi-node output can be optimized, the limit of an optimization matching algorithm is broken, the optimization degree of the neural network model can be greatly improved, the storage space occupied by the neural network model can be greatly reduced, and the calculation efficiency of the neural network model can be greatly improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings that are required to be used in the description of the embodiments of the present application will be briefly described below.
FIG. 1 is a schematic flow chart of a model structure optimization method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of a model structure optimization method according to an embodiment of the present application;
FIG. 3 is a flow chart of a model structure optimization method in an example of an embodiment of the application;
FIG. 4 is a block diagram of a model structure optimizing apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below with reference to the drawings in the present application. It should be understood that the embodiments described below with reference to the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and the technical solutions of the embodiments of the present application are not limited.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and "comprising," when used in this specification, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, all of which may be included in the present specification. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates that at least one of the items defined by the term, e.g., "a and/or B" may be implemented as "a", or as "B", or as "a and B".
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
The technical solutions of the embodiments of the present application and technical effects produced by the technical solutions of the present application are described below by describing several exemplary embodiments. It should be noted that the following embodiments may be referred to, or combined with each other, and the description will not be repeated for the same terms, similar features, similar implementation steps, and the like in different embodiments.
Fig. 2 is a schematic flow chart of a method for optimizing a model structure according to an embodiment of the present application, where an execution subject of the method may be a terminal (e.g., a computer, a mobile phone, etc.), and as shown in fig. 2, the method may include:
step S101, acquiring a node structure of a target model, and determining a target optimization structure in the node structure; the target optimization structure comprises a father node and at least two child nodes corresponding to the father node.
Wherein the target model may be a neural network model. The neural network model is composed of a plurality of nodes, so that the node structure corresponding to the target model can be acquired. The target optimization structure is a part of the node structure, which needs to be optimized, and consists of a father node and at least two child nodes directly connected with the father node.
Specifically, before optimizing the target model, node structure information forming the target model needs to be acquired, and then a target optimization structure needing to be optimized is determined from the node structures.
Step S102, determining an original output node of each sub-node, adding a first node, taking the first node as a new output node of at least two sub-nodes, and taking the first node as an input node of the original output node.
The original output node is an output node of the child node in the node structure, as shown in fig. 3, the node C is an original output node of the node B0, and the node D is an original output node of the node B1. The first node is node T newly generated after node B0 and node B1.
Specifically, after determining the target optimization structure, the original output node of each sub-node in the target optimization structure may be determined first, then a first node may be added after the level where the sub-node is located, and meanwhile, the output node of each sub-node is adjusted from the corresponding original output node to the first node, and then the input node of each original output node is also adjusted to the first node.
Step S103, taking the target optimization structure and the first node as a structure to be replaced, and adopting a second node to replace the structure to be replaced to obtain an optimized node structure; wherein the execution algorithm of the second node is the same as the execution algorithm of the structure to be replaced.
The structure to be replaced is composed of a target optimization structure and a first node. The second node is used for replacing the node of the structure to be replaced, and in fig. 3, the node N is the second node.
Specifically, after the first node is newly built and links are established with other nodes, a structure conforming to the rule of the optimization matching algorithm is formed from the father node of the target optimization structure to the first node, so that the structure of the part can be replaced by the second node, and the optimization of the structure of the part is realized.
According to the scheme provided by the application, the new node is created after the plurality of output nodes, and the optimization structure of the model is adjusted to be in a single-node output form, so that the structure of the multi-node output can be optimized, the limit of an optimization matching algorithm is broken, the optimization degree of the neural network model can be greatly improved, the storage space occupied by the neural network model can be greatly reduced, and the calculation efficiency of the neural network model can be greatly improved.
In an optional embodiment of the present application, before the first node is newly added, the method specifically further includes:
determining a target dominant point in the node structure according to the target optimization structure; the target dominant point is a common node which is closest to each child node after the execution sequence in the node structure is in the target optimization structure and is in the process of traversing each child node simultaneously in the sequence reverse to the execution sequence;
The method for adding the first node specifically comprises the following steps:
and adding the first node based on the target dominant point.
The target dominant point may be the nearest child node, and is a common child node directly connected or indirectly connected to each child node, in fig. 3, the target dominant point is node E.
Specifically, according to the child nodes in the target optimization structure and the node structure of the target model, a target dominant point related to the target optimization structure can be found, and then based on the target dominant point and the node structure, a first node is newly built at a level adjacent to each child node after the execution sequence of each child node.
Optionally, in the embodiment of the present application, each node may store structural information of a node structure that is directly connected or indirectly connected to the node before the node, each arrow in the graph may represent an output value of the node, and the output value may be used to represent corresponding structural information, so that whether a target optimization structure exists before the target dominant point may also be determined according to the structural information contained in the target dominant point. If the target optimization structure exists, a first node can be newly built after each child node level of the target optimization structure.
In an alternative embodiment of the present application, the adding of the first node based on the target dominant point specifically includes:
traversing each node in sequence based on the execution sequence of each node in the node structure, acquiring a first sub-node if the execution sequence comprises a target optimization structure in the structure before the target dominant point, and adding a first node between the first sub-node and a first output node based on the node structure; the first child node is any node in all child nodes, and the first output node is an original output node of the first child node.
Specifically, the positions of the target optimization structure and the target dominant point may be determined according to the execution sequence between the nodes, and if the target optimization structure exists before the target dominant point, it means that the target optimization structure may be optimized. At this time, any child node is selected from the target optimization structure as a first child node, and then a first node is newly added between the first child node and the first output node according to the relation between the first child node and the first output node.
In an alternative embodiment of the present application, after the first node is the new output node of the at least two child nodes, the method specifically includes:
Storing the output value of each second child node into the first node; the second child node is other nodes except the first child node in each child node;
for each output value, generating a key value pair for the output value and the corresponding second child node;
the method for using the first node as the input node of the original output node specifically comprises the following steps:
regarding a first output node, taking the first node as an input node of the first output node based on the corresponding relation between the first child node and the first output node;
for each second output node, determining a corresponding second child node based on the node structure, and taking the first node as an input node of the second output node according to the key value pair related to the second child node; the second output node is an original output node of the second child node.
The key value pair is used for representing the corresponding relation between the node and the node output value.
Specifically, when the first node is used as a new output node of each sub-node, the input node of the original output node of each sub-node needs to be adjusted. Specifically, for the first output node, since the first node is newly added between the first child node and the first output node, the first node may be directly used as an input node of the first output node based on the correspondence between the first child node and the first output node; for each second output node, the output value of each second sub-node is firstly stored in the first node, a corresponding key value pair is generated for each second sub-node, then whether each second output node has a corresponding second sub-node or not is judged based on the original node structure, and if so, the input node of the second output node is further adjusted to be the first node according to the corresponding key value pair; if not, no further adjustment is performed.
In an optional embodiment of the application, after generating the key value pair related to the output value and the corresponding second child node, the method specifically further comprises:
storing each key value pair into a preset dictionary;
the input node using the first node as the second output node according to the key value pair related to the second child node specifically comprises:
and acquiring a key value pair related to the second child node from the preset dictionary, and taking the first node as an input node of the second output node according to the key value pair.
The preset dictionary may be a data structure in the database for storing key-value pairs.
Specifically, the output value and the key value pair of the second sub-node may be stored in a preset dictionary, and read from the preset dictionary when the input node of each second output node needs to be adjusted. And when the input node of the second output node is adjusted each time, judging whether the corresponding key value pair can be read from the preset dictionary. If yes, adjusting the input node of the second output node to be the first node; if not, no adjustment is performed.
In an alternative embodiment of the present application, the input node using the first node as the second output node according to the key value pair specifically includes:
And acquiring a key value of the key value pair, and adjusting the input value of the second output node to a corresponding output value stored in the first node according to the key value.
Specifically, if a corresponding key value pair exists in the preset dictionary, the key value of the key value pair is read, and the input of the second output node is adjusted to be the output value corresponding to the key value stored in the first node, so that the process of adjusting the input node of the second output node to be the first node is realized.
In an alternative embodiment of the present application, the target optimization structure and the first node are used as a structure to be replaced, and the second node is used to replace the structure to be replaced, so as to obtain an optimized node structure, which specifically includes:
taking a father node of the target optimization structure as a starting point of the structure to be replaced and taking the first node as an ending point of the structure to be replaced;
and replacing the structure to be replaced with the second node by an optimized matching algorithm based on the starting point and the ending point.
Wherein the starting point represents a first node point experienced by traversing the structure to be optimized in the order of execution. The termination point represents the last node traversed in execution order through the structure to be optimized. An optimized matching algorithm is an algorithm that replaces a node structure for replacing a node structure with an input of only a single node and an output of only a single node.
Specifically, in the embodiment of the present application, since the first node is added after the child node in the target optimization structure, the parent node in the structure to be replaced may be used as a starting point, and the newly added first node may be used as an ending point, and then the structure to be replaced is replaced. For example, as shown in fig. 3, a-B0-B1-T is a structure to be replaced, node a is a parent node of the target optimization structure a-B0-B1, and node T is a first node, so that node a can be used as a starting point of the structure to be replaced, node T is used as an ending point of the structure to be replaced, and then the structure to be replaced a-B0-B1-T is replaced with a second node N by adopting an optimization matching algorithm, thereby realizing optimization of the node structure.
Fig. 4 is a block diagram of a model structure optimization device according to an embodiment of the present application, and as shown in fig. 4, the model structure optimization device 400 may include: a target optimization structure acquisition module 401, a node generation module 402, and a node structure optimization module 403, wherein,
the target optimization structure acquisition module 401 is configured to acquire a node structure of the target model, and determine a target optimization structure in the node structure; the target optimization structure comprises a father node and at least two child nodes corresponding to the father node;
The node generating module 402 is configured to determine an original output node of each child node, add a first node, use the first node as a new output node of at least two child nodes, and use the first node as an input node of the original output node;
the node structure optimization module 403 is configured to replace the structure to be replaced with a second node by using the target optimization structure and the first node as the structure to be replaced, so as to obtain an optimized node structure; wherein the execution algorithm of the second node is the same as the execution algorithm of the structure to be replaced.
According to the scheme provided by the application, the new node is created after the plurality of output nodes, and the optimization structure of the model is adjusted to be in a single-node output form, so that the structure of the multi-node output can be optimized, the limit of an optimization matching algorithm is broken, the optimization degree of the neural network model can be greatly improved, the storage space occupied by the neural network model can be greatly reduced, and the calculation efficiency of the neural network model can be greatly improved.
In an alternative embodiment of the present application, the apparatus further includes a target dominant point acquisition module, specifically configured to:
determining a target dominant point in the node structure according to the target optimization structure; the target dominant point is a common node which is closest to each child node after the execution sequence in the node structure is in the target optimization structure and is in the process of traversing each child node simultaneously in the sequence reverse to the execution sequence;
The node generation module is specifically configured to:
and adding the first node based on the target dominant point.
In an alternative embodiment of the application, the node generating module is further configured to:
traversing each node in sequence based on the execution sequence of each node in the node structure, acquiring a first sub-node if the execution sequence comprises a target optimization structure in the structure before the target dominant point, and adding a first node between the first sub-node and a first output node based on the node structure; the first child node is any node in all child nodes, and the first output node is an original output node of the first child node.
In an optional embodiment of the application, the apparatus further comprises a key value pair generating module, specifically configured to:
storing the output value of each second child node into the first node; the second child node is other nodes except the first child node in each child node;
for each output value, generating a key value pair for the output value and the corresponding second child node;
the node generation module may also be configured to:
regarding a first output node, taking the first node as an input node of the first output node based on the corresponding relation between the first child node and the first output node;
For each second output node, determining a corresponding second child node based on the node structure, and taking the first node as an input node of the second output node according to the key value pair related to the second child node; the second output node is an original output node of the second child node.
In an alternative embodiment of the present application, the apparatus further includes a key value pair storage module, specifically configured to:
storing each key value pair into a preset dictionary;
the node generation module may also be configured to:
and acquiring a key value pair related to the second child node from the preset dictionary, and taking the first node as an input node of the second output node according to the key value pair.
In an alternative embodiment of the application, the node generating module may be further configured to:
and acquiring a key value of the key value pair, and adjusting the input value of the second output node to a corresponding output value stored in the first node according to the key value.
In an alternative embodiment of the present application, the node structure optimization module is specifically configured to:
taking a father node of the target optimization structure as a starting point of the structure to be replaced and taking the first node as an ending point of the structure to be replaced;
and replacing the structure to be replaced with the second node by an optimized matching algorithm based on the starting point and the ending point.
Referring now to fig. 5, a schematic diagram of an electronic device (e.g., a terminal device or server performing the method of fig. 2) 500 suitable for use in implementing embodiments of the present application is shown. The electronic device in the embodiment of the present application may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a car-mounted terminal (e.g., car navigation terminal), a wearable device, etc., and a fixed terminal such as a digital TV, a desktop computer, etc. The electronic device shown in fig. 5 is only an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present application.
An electronic device includes: the memory is used for storing programs for executing the methods according to the method embodiments; the processor is configured to execute a program stored in the memory. Herein, the processor may be referred to as a processing device 501, which is described below, and the memory may include at least one of a Read Only Memory (ROM) 502, a Random Access Memory (RAM) 503, and a storage device 508, which are described below, specifically as follows:
As shown in fig. 5, the electronic device 500 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 501, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data required for the operation of the electronic apparatus 500 are also stored. The processing device 501, the ROM 502, and the RAM503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
In general, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 507 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 508 including, for example, magnetic tape, hard disk, etc.; and communication means 509. The communication means 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 shows an electronic device having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present application, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 509, or from the storage means 508, or from the ROM 502. The above-described functions defined in the method of the embodiment of the present application are performed when the computer program is executed by the processing means 501.
The computer readable storage medium of the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to:
acquiring a node structure of a target model, and determining a target optimization structure in the node structure; the target optimization structure comprises a father node and at least two child nodes corresponding to the father node; determining an original output node of each child node respectively, adding a first node newly, taking the first node as a new output node of at least two child nodes, and taking the first node as an input node of the original output node; taking the target optimization structure and the first node as a structure to be replaced, and adopting a second node to replace the structure to be replaced to obtain an optimized node structure; wherein the execution algorithm of the second node is the same as the execution algorithm of the structure to be replaced.
Computer program code for carrying out operations of the present application may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units involved in the embodiments of the present application may be implemented in software or in hardware. Where the name of the module or unit does not constitute a limitation of the unit itself in some cases, for example, the first constraint acquisition module may also be described as "a module that acquires the first constraint".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of the present application, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited in order and may be performed in other orders, unless explicitly stated herein. Moreover, at least some of the steps in the flowcharts of the figures may include a plurality of sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, the order of their execution not necessarily being sequential, but may be performed in turn or alternately with other steps or at least a portion of the other steps or stages.
The foregoing is only a partial embodiment of the present invention, and it should be noted that it will be apparent to those skilled in the art that modifications and adaptations can be made without departing from the principles of the present invention, and such modifications and adaptations are intended to be comprehended within the scope of the present invention.

Claims (10)

1. A method for optimizing a model structure, comprising:
acquiring a node structure of a target model, and determining a target optimization structure in the node structure; the target optimization structure comprises a father node and at least two child nodes corresponding to the father node;
Determining an original output node of each child node respectively, adding a first node newly, taking the first node as a new output node of the at least two child nodes, and taking the first node as an input node of the original output node;
taking the target optimization structure and the first node as a structure to be replaced, and replacing the structure to be replaced by a second node to obtain an optimized node structure; the execution algorithm of the second node is the same as the execution algorithm of the structure to be replaced.
2. The method of claim 1, further comprising, prior to the adding the first node:
determining a target dominant point in the node structure according to the target optimization structure; the target dominant point is a common node which is closest to each sub-node after the execution sequence in the node structure is in the target optimization structure and is necessary in the process of traversing each sub-node simultaneously in the reverse sequence of the execution sequence;
the newly added first node includes:
and newly adding the first node based on the target dominant point.
3. The method of claim 2, wherein the adding the first node based on the target dominant point comprises:
Traversing each node in turn based on the execution sequence of each node in the node structure, if the execution sequence includes the target optimization structure in the structure before the target dominant point, acquiring a first sub-node, and newly adding the first node between the first sub-node and a first output node based on the node structure; the first sub-node is any node in all sub-nodes, and the first output node is an original output node of the first sub-node.
4. A method according to claim 3, characterized in that after said taking the first node as a new output node for the at least two child nodes, it comprises:
storing the output value of each second child node into the first node; the second child node is other nodes except the first child node in all child nodes;
for each output value, generating a key-value pair for the output value and a corresponding second child node;
the input node using the first node as the original output node includes:
for the first output node, taking the first node as an input node of the first output node based on the corresponding relation between the first child node and the first output node;
For each second output node, determining a corresponding second child node based on the node structure, and taking the first node as an input node of the second output node according to a key value pair related to the second child node; wherein the second output node is an original output node of the second child node.
5. The method of claim 4, wherein after generating the key-value pair for the output value and the corresponding second child node, further comprising:
storing each key value pair into a preset dictionary;
the input node using the first node as the second output node according to the key value pair about the second child node includes:
and acquiring a key value pair related to the second child node from the preset dictionary, and taking the first node as an input node of the second output node according to the key value pair.
6. The method according to claim 5, wherein said taking the first node as an input node for the second output node according to the key-value pair comprises:
and acquiring the key value of the key value pair, and adjusting the input value of the second output node to the corresponding output value stored in the first node according to the key value.
7. The method according to claim 1, wherein the replacing the target optimization structure and the first node with the second node as the structure to be replaced to obtain the optimized node structure includes:
taking a father node of the target optimization structure as a starting point of the structure to be replaced and taking the first node as an ending point of the structure to be replaced;
and replacing the structure to be replaced with a second node through an optimization matching algorithm based on the starting point and the ending point.
8. A model structure optimizing apparatus, characterized by comprising:
the target optimization structure acquisition module is used for acquiring a node structure of the target model and determining a target optimization structure in the node structure; the target optimization structure comprises a father node and at least two child nodes corresponding to the father node;
the node generation module is used for respectively determining the original output node of each child node, adding a first node newly, taking the first node as a new output node of the at least two child nodes, and taking the first node as an input node of the original output node;
The node structure optimization module is used for taking the target optimization structure and the first node as a structure to be replaced, and replacing the structure to be replaced by a second node to obtain an optimized node structure; the execution algorithm of the second node is the same as the execution algorithm of the structure to be replaced.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to carry out the steps of the method of any one of claims 1-7.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any of claims 1-7.
CN202311183241.XA 2023-09-13 2023-09-13 Model structure optimization method and device, electronic equipment and storage medium Pending CN117236407A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311183241.XA CN117236407A (en) 2023-09-13 2023-09-13 Model structure optimization method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311183241.XA CN117236407A (en) 2023-09-13 2023-09-13 Model structure optimization method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117236407A true CN117236407A (en) 2023-12-15

Family

ID=89094128

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311183241.XA Pending CN117236407A (en) 2023-09-13 2023-09-13 Model structure optimization method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117236407A (en)

Similar Documents

Publication Publication Date Title
CN113327598B (en) Model training method, voice recognition method, device, medium and equipment
CN111858381B (en) Application fault tolerance capability test method, electronic device and medium
CN111857720B (en) User interface state information generation method and device, electronic equipment and medium
CN113722055A (en) Data processing method and device, electronic equipment and computer readable medium
CN111612434B (en) Method, apparatus, electronic device and medium for generating processing flow
CN113220281A (en) Information generation method and device, terminal equipment and storage medium
WO2023179291A1 (en) Image inpainting method and apparatus, and device, medium and product
CN112507676B (en) Method and device for generating energy report, electronic equipment and computer readable medium
CN113610228B (en) Method and device for constructing neural network model
CN117236407A (en) Model structure optimization method and device, electronic equipment and storage medium
CN112000667B (en) Method, apparatus, server and medium for retrieving tree data
CN111680754B (en) Image classification method, device, electronic equipment and computer readable storage medium
CN111626044B (en) Text generation method, text generation device, electronic equipment and computer readable storage medium
CN111580890A (en) Method, apparatus, electronic device, and computer-readable medium for processing features
CN114040014B (en) Content pushing method, device, electronic equipment and computer readable storage medium
CN114697206B (en) Method, device, equipment and computer readable medium for managing nodes of Internet of things
CN110908867B (en) Task completion judging method and device, storage medium and electronic equipment
CN110837475B (en) Redundancy detection method and device, terminal and storage medium
CN116483808B (en) Data migration method, device, electronic equipment and computer readable medium
CN115565607B (en) Method, device, readable medium and electronic equipment for determining protein information
CN111582482B (en) Method, apparatus, device and medium for generating network model information
CN116319322B (en) Power equipment node communication connection method, device, equipment and computer medium
CN116107666B (en) Program service flow information generation method, device, electronic equipment and computer medium
CN116467178B (en) Database detection method, apparatus, electronic device and computer readable medium
CN111625692B (en) Feature extraction method, device, electronic equipment and computer readable medium

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