Open neural network model modification method, apparatus and device, and readable medium
By creating and parsing modified configuration files, and automatically performing modification operations of open neural network models, the problems of inflexible modification and error-prone existing tools are solved, and efficient and flexible model modification is achieved.
Patent Information
- Application Number
- CN202510050746.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-04-15
AI Technical Summary
The existing model modification tools lack flexibility in modifying the ONNX model and cannot fully meet the user's custom needs. Moreover, errors are prone to occur when users manually modify, resulting in the model not working normally.
Provide a method for modifying an open neural network model. By creating a modification configuration file, parsing the configuration file to obtain relevant information of the modification operation, determining the modification operation type, and configuring the corresponding operation function to perform the modification operation, and finally building the target model.
It realizes flexible modification of the ONNX model, reduces human errors, improves operation efficiency, and meets various modification needs of users.
Smart Images

Figure CN119830985A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of model technology, and in particular to a method for modifying an open neural network model, a device for modifying an open neural network model, an electronic device, and a computer-readable medium. Background Art
[0002] In the related technologies in the field of deep learning and artificial intelligence, the ONNX (Open Neural Network Exchange) format is widely used for cross-platform and cross-framework model exchange. The ONNX model provides a standardized way to allow models between different deep learning frameworks to be converted to each other. However, in practical applications, various modifications, adjustments, and optimizations of the ONNX model are often required to meet specific needs.
[0003] However, in the related art, users need to have high professional knowledge when using existing model modification tools to modify ONNX models. When dealing with complex modification requirements, existing model modification tools lack flexibility and can only modify ONNX models according to specific rules. They cannot fully meet users' customized needs or very differentiated needs, and the ONNX model modification methods provided in the related art are specific, and no general ONNX model modification method is provided. In addition, since the modification of ONNX models usually involves multiple steps, when users manually use modification tools to modify ONNX models, errors are likely to occur during the operation, causing the model to fail to work properly. Summary of the invention
[0004] The embodiments of the present invention provide a method, device, electronic device and computer-readable storage medium for modifying an open neural network model, so as to at least solve the problem that existing model modification tools lack flexibility and can only modify ONNX models according to specific rules, but cannot fully meet the user's customized needs or very differentiated needs, and when users manually use modification tools to modify ONNX models, errors are likely to occur during the operation, resulting in the model not being able to work properly.
[0005] The embodiment of the present invention discloses a method for modifying an open neural network model, which is applied to a model modification tool. The method includes:
[0006] Creating a modification configuration file of the open neural network model based on a modification target of the user for the preset open neural network model;
[0007] Parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model;
[0008] Determining a type of the modification operation based on the relevant information of the modification operation;
[0009] Based on the type of the modification operation, configuring an operation function for executing the modification operation for the model modification tool;
[0010] Using the operation function, performing the modification operation on the open neural network model;
[0011] According to the modification result of the modification operation, a target open neural network model is constructed.
[0012] Optionally, parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model includes:
[0013] The modification configuration file is parsed to obtain an operation node list of the open neural network model; the operation node list includes at least one operation node; and the operation node contains relevant information of the modification operation of the open neural network model.
[0014] Optionally, the method comprises:
[0015] Based on the operation node list, determining an order of the at least one operation node in the operation node list;
[0016] Using the order of the operation nodes as the execution order of the modification operations corresponding to the operation nodes;
[0017] The using the operation function to perform the modification operation on the open neural network model includes:
[0018] Based on the execution order of the modification operations, the modification operations are executed using the operation functions.
[0019] Optionally, the modification operation includes at least one of modifying an input of the open neural network model, modifying an output of the open neural network model, and modifying a computing node of the open neural network model.
[0020] Optionally, the model modification tool is in communication with a preset storage device; and the parsing of the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model includes:
[0021] Parse the modified configuration file to obtain the original file path and output file path of the open neural network model in the storage device.
[0022] Optionally, the using the operation function to perform the modification operation on the open neural network model includes:
[0023] Based on the original file path, obtaining the open neural network model from the storage device;
[0024] Parsing the open neural network model to obtain an input tensor list, an output tensor list, and a computing node tensor list of the open neural network model;
[0025] Modifying the input of the open neural network model by modifying the input tensor list;
[0026] Modifying the output of the open neural network model by modifying the output tensor list;
[0027] The computing nodes of the open neural network model are modified by modifying the computing node tensor list.
[0028] Optionally, constructing a target open neural network model according to a modification result of the modification operation includes:
[0029] Constructing the target open neural network model according to the modified input tensor list, the modified output tensor list and the modified computing node tensor list;
[0030] The target open neural network model is stored on the storage device through the output file path.
[0031] The embodiment of the present invention further discloses a modification device for an open neural network model, which is applied to a model modification tool. The device comprises:
[0032] A creation module, used to create a modification configuration file of the open neural network model based on a modification target of the user for the preset open neural network model;
[0033] A parsing module, used for parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model;
[0034] A type determination module, used to determine the type of the modification operation based on the relevant information of the modification operation;
[0035] An operation function configuration module, configured to configure an operation function for executing the modification operation for the model modification tool based on the type of the modification operation;
[0036] A modification operation execution module, used to perform the modification operation on the open neural network model using the operation function;
[0037] A construction module is used to construct a target open neural network model according to the modification result of the modification operation.
[0038] Optionally, the parsing module includes:
[0039] The first parsing submodule is used to parse the modification configuration file to obtain an operation node list of the open neural network model; the operation node list includes at least one operation node; the operation node contains relevant information of the modification operation of the open neural network model.
[0040] Optionally, the device comprises:
[0041] An order determination module, configured to determine the order of at least one operation node in the operation node list based on the operation node list;
[0042] The execution order is used as a module to use the order of the operation nodes as the execution order of the modification operations corresponding to the operation nodes;
[0043] The modification operation execution module includes:
[0044] An execution submodule is used to execute the modification operation using the operation function based on the execution order of the modification operation.
[0045] Optionally, the modification operation includes at least one of modifying an input of the open neural network model, modifying an output of the open neural network model, and modifying a computing node of the open neural network model.
[0046] Optionally, the model modification tool is communicatively connected to a preset storage device; and the parsing module includes:
[0047] The second parsing submodule is used to parse the modified configuration file to obtain the original file path and output file path of the open neural network model in the storage device.
[0048] Optionally, the modification operation execution module includes:
[0049] An acquisition submodule, used for acquiring the open neural network model from the storage device based on the original file path;
[0050] A third parsing submodule is used to parse the open neural network model to obtain an input tensor list, an output tensor list and a computing node tensor list of the open neural network model;
[0051] A first modification submodule, used to modify the input of the open neural network model by modifying the input tensor list;
[0052] A second modification submodule, used to modify the output of the open neural network model by modifying the output tensor list;
[0053] The third modification submodule is used to modify the computing nodes of the open neural network model by modifying the computing node tensor list.
[0054] Optionally, the building blocks include:
[0055] A construction submodule, used to construct the target open neural network model according to the modified input tensor list, the modified output tensor list and the modified computing node tensor list;
[0056] The storage submodule is used to store the target open neural network model on the storage device through the output file path.
[0057] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0058] The memory is used to store computer programs;
[0059] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0060] The embodiment of the present invention further discloses one or more computer-readable media on which instructions are stored. When executed by one or more processors, the processors are enabled to execute the method described in the embodiment of the present invention.
[0061] The embodiments of the present invention include the following advantages:
[0062] In an embodiment of the present invention, a model modification tool creates a modification configuration file of an open neural network model based on a user's modification target for a preset open neural network model; parses the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model; determines the type of the modification operation based on the relevant information of the modification operation; configures an operation function for executing the modification operation for the model modification tool based on the type of the modification operation; executes the modification operation on the open neural network model using the operation function; and constructs a target open neural network model according to the modification result of the modification operation. An embodiment of the present invention provides a model modification tool based on script configuration, which realizes parsing the modification configuration file using the model modification tool, and automatically executes various modification operations on the open neural network model to reduce human errors, improve operational efficiency, and avoid errors that occur easily during the operation process when the user manually uses the modification tool to modify the ONNX model, resulting in the model not being able to work properly. In addition, the modification configuration file created by the model modification tool according to the user's modification target for the open neural network model supports multiple types of modification operations on the ONNX model to meet the different needs of users. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 is a flowchart of a method for modifying an open neural network model provided in an embodiment of the present invention;
[0064] Figure 2 is a flowchart of the steps of another method for modifying an open neural network model provided in an embodiment of the present invention;
[0065] Figure 3 is a structural block diagram of a device for modifying an open neural network model provided in an embodiment of the present invention;
[0066] Figure 4 is a block diagram of an electronic device provided in an embodiment of the present invention;
[0067] Figure 5 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0068] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0069] Reference Figure 1 , shows a flowchart of a method for modifying an open neural network model provided in an embodiment of the present invention, which is applied to a model modification tool and may specifically include the following steps:
[0070] Step 101, based on a user's modification target for a preset open neural network model, creating a modification configuration file of the open neural network model;
[0071] In an embodiment of the present invention, the model modification tool may be a model modifier. The model modification tool may modify the open neural network model to obtain a target open neural network model. The open neural network model may be an ONNX model.
[0072] In an embodiment of the present invention, the modification targets of the user for the open neural network model may include: modifying, adding, and deleting the input and output of the model, renaming the computing nodes and tensors in the model, and adding, modifying, and deleting the computing nodes and tensors in the model. It should be noted that the tensors in the model include all transmitted data in the open neural network model, which may include input tensors and output tensors of computing nodes. The configuration file may refer to a YAML configuration file.
[0073] In an embodiment of the present invention, a user can create a modification configuration file of the open neural network model according to the modification target of the open neural network model, and define various modification operations for the open neural network model. Then the modification configuration file is input into the model modification tool. The model modification tool can also create a modification configuration file based on the modification target of the user for the open neural network model.
[0074] Step 102, parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model;
[0075] In an embodiment of the present invention, the model modification tool parses the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model. The relevant information may include information such as the type and parameters of the modification operation.
[0076] In some embodiments of the present invention, parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model includes:
[0077] The modification configuration file is parsed to obtain an operation node list of the open neural network model; the operation node list includes at least one operation node; and the operation node contains relevant information of the modification operation of the open neural network model.
[0078] In an embodiment of the present invention, a modification configuration file of an open neural network model may include an operation node list. The operation node list may include at least one operation node. Each operation node corresponds to a modification operation of the open neural network model, and each operation node includes relevant information of a modification operation of the open neural network model. It should be noted that a plurality of operation nodes corresponding to the same modification operation may be included in the modification configuration file. When creating a modification configuration file, a user or a model modification tool may increase the level of detail of the operation node, including improving the relevant information of the modification operation, thereby improving the readability and understandability of the modification configuration file.
[0079] In an embodiment of the present invention, when parsing and modifying the configuration file to obtain relevant information of at least one modification operation of the open neural network model, the model modification tool can obtain a list of operation nodes of the open neural network model.
[0080] In some embodiments of the invention, the method comprises:
[0081] Based on the operation node list, determining an order of the at least one operation node in the operation node list;
[0082] Using the order of the operation nodes as the execution order of the modification operations corresponding to the operation nodes;
[0083] In an embodiment of the present invention, the operation node list may include at least one operation node, and each operation node corresponds to a modification operation of the open neural network model. At least one operation node in the operation node list is in order. Based on the operation node list, the model modification tool can determine the order of at least one operation node in the operation node list, and use the order of the operation node as the execution order of the modification operation corresponding to the operation node. When modifying the open neural network model, the model modification tool can perform the modification in the execution order of the modification operation.
[0084] In some embodiments of the present invention, the model modification tool is in communication with a preset storage device; and the parsing of the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model includes:
[0085] Parse the modified configuration file to obtain the original file path and output file path of the open neural network model in the storage device.
[0086] In an embodiment of the present invention, the open neural network model to be modified can be stored in a storage device, and the storage device is in communication with the model modification tool. When parsing and modifying the configuration file, the model modification tool can obtain the original file path of the open neural network model to be modified in the storage device and the output file path of the modified target open neural network model in the storage device. The storage device can refer to a disk.
[0087] In an embodiment of the present invention, through the original file path, the model modification tool can obtain the open neural network model to be modified from the storage device; through the output file path, the model modification tool can store the target open neural network model on the storage device.
[0088] Step 103, determining the type of the modification operation based on the relevant information of the modification operation;
[0089] In an embodiment of the present invention, modifying an operation node in a configuration file may include relevant information of the modification operation. The relevant information may include a mode parameter, and the mode parameter is used to identify the type of the modification operation corresponding to the operation node. Therefore, based on the relevant information of the modification operation, the type of the modification operation may be determined.
[0090] In some embodiments of the present invention, the modification operation includes at least one of modification of an input of the open neural network model, modification of an output of the open neural network model, and modification of a computing node of the open neural network model.
[0091] In an embodiment of the present invention, the type of modification operation may include at least one of modification of the input of the open neural network model, modification of the output of the open neural network model, and modification of the computing nodes of the open neural network model. In addition, the type of modification operation may also include renaming of computing nodes and tensors in the model, and modification of tensors in the model. Specifically, if mode is input, the type of modification operation is to modify the input of the model; if mode is output, the type of modification operation is to modify the output of the model; if mode is name, the type of modification operation is to modify the name of the tensor or computing node in the model; if mode is tensor, the type of modification operation is to add, delete, and modify tensors in the model; if mode is node, the type of modification operation is to add, delete, and modify computing nodes in the model.
[0092] Step 104, based on the type of the modification operation, configuring an operation function for executing the modification operation for the model modification tool;
[0093] In an embodiment of the present invention, based on the type of modification operation, an operation function for executing the modification operation can be configured for the model modification tool. It should be noted that if a new type of modification operation is added to an existing old modification configuration file, a corresponding operation function can be added to the program of the model modification tool to update the model modification tool. The updated model modification tool can be compatible with the old modification configuration file and does not affect the parsing and execution of the old modification configuration file.
[0094] Step 105, using the operation function to perform the modification operation on the open neural network model;
[0095] In the embodiment of the present invention, based on the type of modification operation, an operation function for performing the modification operation can be configured for the model modification tool. The model modification tool can perform the modification operation on the open neural network model using the operation function.
[0096] In some embodiments of the present invention, the using the operation function to perform the modification operation on the open neural network model includes:
[0097] Based on the execution order of the modification operations, the modification operations are executed using the operation functions.
[0098] Specifically, based on the operation node list, the model modification tool can determine the order of at least one operation node in the operation node list, and use the order of the operation nodes as the execution order of the modification operations corresponding to the operation nodes. When the model modification tool uses the operation function to modify the open neural network model, it can be based on the execution order of the modification operations.
[0099] In some embodiments of the present invention, the using the operation function to perform the modification operation on the open neural network model includes:
[0100] Based on the original file path, obtaining the open neural network model from the storage device;
[0101] Parsing the open neural network model to obtain an input tensor list, an output tensor list, and a computing node tensor list of the open neural network model;
[0102] Modifying the input of the open neural network model by modifying the input tensor list;
[0103] Modifying the output of the open neural network model by modifying the output tensor list;
[0104] The computing nodes of the open neural network model are modified by modifying the computing node tensor list.
[0105] In an embodiment of the present invention, in the process of the model modification tool using the operation function to perform the modification operation on the open neural network model, the model modification tool can obtain the open neural network model to be modified from the storage device based on the original file path. The model modification tool parses the open neural network model to be modified, and can obtain the input tensor list, output tensor list and computing node tensor list of the open neural network model to be modified. The model modification tool can modify, add and delete the input of the open neural network model by modifying the input tensor list; the model modification tool can modify, add and delete the output of the open neural network model by modifying the output tensor list; the model modification tool can modify, add, delete and rename the computing nodes of the open neural network model by modifying the computing node tensor list. In addition, by modifying the computing node tensor list, the model modification tool can also modify, add, delete and rename the tensors in the open neural network model.
[0106] Step 106: construct a target open neural network model according to the modification result of the modification operation.
[0107] In an embodiment of the present invention, the model modification tool can construct a target open neural network model according to the modification result of the modification operation.
[0108] In some embodiments of the present invention, constructing a target open neural network model according to the modification result of the modification operation includes:
[0109] Constructing the target open neural network model according to the modified input tensor list, the modified output tensor list and the modified computing node tensor list;
[0110] The target open neural network model is stored on the storage device through the output file path.
[0111] In an embodiment of the present invention, the model modification tool can modify the input of the open neural network model by modifying the input tensor list, can modify the output of the open neural network model by modifying the output tensor list, and can modify the computing nodes and tensors in the open neural network model by modifying the computing node tensor list. According to the modified input tensor list, the modified output tensor list, and the modified computing node tensor list, the model modification tool can construct the target open neural network model.
[0112] Specifically, the model modification tool modifies the shape or type of the input tensors of the open neural network model to be modified, adds new input tensors to the open neural network model to be modified, and deletes input tensors that are no longer needed, based on the modified input tensor list. Modify the source nodes of the output tensors of the open neural network model to be modified, add new output tensors to the open neural network model to be modified, and delete output tensors that are no longer needed, based on the modified output tensor list. Modify the operations or parameters of the nodes of the open neural network model to be modified, add new computing nodes to the model, delete computing nodes that are no longer needed, rename computing nodes and tensors in the model, and modify, add or delete tensors in the model, based on the modified computing node tensor list.
[0113] In an embodiment of the present invention, the model modification tool can store the target open neural network model on a storage device by outputting a file path.
[0114] In an embodiment of the present invention, a model modification tool creates a modification configuration file of an open neural network model based on a modification target of a preset open neural network model by a user; parses the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model; determines the type of the modification operation based on the relevant information of the modification operation; configures an operation function for executing the modification operation for the model modification tool based on the type of the modification operation; executes the modification operation on the open neural network model using the operation function; and constructs a target open neural network model according to the modification result of the modification operation. An embodiment of the present invention provides a model modification tool based on script configuration, which realizes parsing the modification configuration file using the model modification tool and automatically executes various modification operations on the open neural network model to reduce human errors, improve operation efficiency, and avoid the problem that when a user manually uses the modification tool to modify the ONNX model, errors are likely to occur during the operation process, resulting in the model not being able to work properly. In addition, the modification configuration file created by the model modification tool according to the modification target of the open neural network model by the user supports multiple types of modification operations on the ONNX model, and the order of different modification operations can be modified to meet the different needs of users.
[0115] Reference Figure 2 , shows a flowchart of the steps of another method for modifying an open neural network model provided in an embodiment of the present invention, which may specifically include the following steps:
[0116] Step 201: Input the configuration file into the model modification tool.
[0117] The model modification tool creates a modification configuration file of the open neural network model based on the modification target of the user for the open neural network model, and inputs the modification configuration file into the model modification tool.
[0118] Step 202, read and parse the configuration file. After step 202 is completed, step 203, step 207 and step 212 are executed.
[0119] The model modification tool parses the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model, determines the type of the modification operation based on the relevant information of the modification operation, and configures an operation function for executing the modification operation for the model modification tool based on the type of the modification operation.
[0120] Step 203, read the ONNX model path to be modified.
[0121] The model modification tool parses and modifies the configuration file to obtain the original file path of the open neural network model in the storage device.
[0122] Step 204: Obtain the ONNX model file to be modified from the storage device, and load the ONNX model.
[0123] Based on the original file path, the model modification tool obtains the open neural network model to be modified from the storage device.
[0124] Step 205, parse the ONNX model.
[0125] Step 206, obtaining an input tensor list, an output tensor list, and a computing node list. After step 206 is completed, step 213 is executed.
[0126] The model modification tool parses the open neural network model to obtain an input tensor list, an output tensor list, and a computing node tensor list of the open neural network model.
[0127] Step 207, read the operation node list.
[0128] The model modification tool parses and modifies the configuration file to obtain an operation node list of the open neural network model. The operation node list includes at least one operation node. The operation node contains relevant information of the modification operation of the open neural network model.
[0129] Step 208: Set the first operation node as the current operation node.
[0130] Step 209, execute the current operation node and modify the model, that is, modify the input tensor list, the output tensor list and the computing node list.
[0131] Step 210, determine whether the current operation node is the last operation node. If yes, execute step 213, if not, execute step 211.
[0132] Step 211, move the current operation node backward by one position. After step 211 is completed, step 209 is executed.
[0133] The model modification tool determines the order of at least one operation node in the operation node list based on the operation node list, and uses the order of the operation nodes as the execution order of the modification operations corresponding to the operation nodes. Based on the execution order of the modification operations, the operation function is used to modify the input tensor list to modify the input of the open neural network model, the output of the open neural network model is modified by modifying the output tensor list, and the computing node of the open neural network model is modified by modifying the computing node tensor list.
[0134] Step 212, read the output ONNX model path.
[0135] The model modification tool parses and modifies the configuration file to obtain the output file path of the open neural network model in the storage device.
[0136] Step 213, generate a new model according to the modified input, output, and calculation nodes, and save it as a file according to the configured path.
[0137] The model modification tool builds a target open neural network model according to the modified input tensor list, the modified output tensor list, and the modified computing node tensor list.
[0138] Step 214, output the modified ONNX model file.
[0139] The model modification tool stores the target open neural network model on a storage device by outputting a file path.
[0140] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0141] Reference Figure 3 , shows a structural block diagram of an open neural network model modification device provided in an embodiment of the present invention, which is applied to a model modification tool and may specifically include the following modules:
[0142] A creation module 301 is used to create a modification configuration file of the open neural network model based on a modification target of the user for the preset open neural network model;
[0143] A parsing module 302, configured to parse the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model;
[0144] A type determination module 303, configured to determine the type of the modification operation based on the relevant information of the modification operation;
[0145] An operation function configuration module 304, configured to configure an operation function for executing the modification operation for the model modification tool based on the type of the modification operation;
[0146] A modification operation execution module 305, used to execute the modification operation on the open neural network model using the operation function;
[0147] The construction module 306 is used to construct a target open neural network model according to the modification result of the modification operation.
[0148] In an optional embodiment of the present invention, the parsing module includes:
[0149] The first parsing submodule is used to parse the modification configuration file to obtain an operation node list of the open neural network model; the operation node list includes at least one operation node; the operation node contains relevant information of the modification operation of the open neural network model.
[0150] In an optional embodiment of the present invention, the device comprises:
[0151] An order determination module, configured to determine the order of at least one operation node in the operation node list based on the operation node list;
[0152] The execution order is used as a module to use the order of the operation nodes as the execution order of the modification operations corresponding to the operation nodes;
[0153] The modification operation execution module includes:
[0154] An execution submodule is used to execute the modification operation using the operation function based on the execution order of the modification operation.
[0155] In an optional embodiment of the present invention, the modification operation includes at least one of modifying the input of the open neural network model, modifying the output of the open neural network model, and modifying the computing nodes of the open neural network model.
[0156] In an optional embodiment of the present invention, the model modification tool is communicatively connected to a preset storage device; and the parsing module includes:
[0157] The second parsing submodule is used to parse the modified configuration file to obtain the original file path and output file path of the open neural network model in the storage device.
[0158] In an optional embodiment of the present invention, the modification operation execution module includes:
[0159] An acquisition submodule, used for acquiring the open neural network model from the storage device based on the original file path;
[0160] A third parsing submodule is used to parse the open neural network model to obtain an input tensor list, an output tensor list and a computing node tensor list of the open neural network model;
[0161] A first modification submodule, used to modify the input of the open neural network model by modifying the input tensor list;
[0162] A second modification submodule, used to modify the output of the open neural network model by modifying the output tensor list;
[0163] The third modification submodule is used to modify the computing nodes of the open neural network model by modifying the computing node tensor list.
[0164] In an optional embodiment of the present invention, the building block includes:
[0165] A construction submodule, used to construct the target open neural network model according to the modified input tensor list, the modified output tensor list and the modified computing node tensor list;
[0166] The storage submodule is used to store the target open neural network model on the storage device through the output file path.
[0167] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0168] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.
[0169] Memory 403, used for storing computer programs;
[0170] The processor 401 is used to execute the program stored in the memory 403 to implement the following steps:
[0171] Creating a modification configuration file of the open neural network model based on a modification target of the user for the preset open neural network model;
[0172] Parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model;
[0173] Determining a type of the modification operation based on the relevant information of the modification operation;
[0174] Based on the type of the modification operation, configuring an operation function for executing the modification operation for the model modification tool;
[0175] Using the operation function, performing the modification operation on the open neural network model;
[0176] According to the modification result of the modification operation, a target open neural network model is constructed.
[0177] In an optional embodiment of the present invention, parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model includes:
[0178] The modification configuration file is parsed to obtain an operation node list of the open neural network model; the operation node list includes at least one operation node; and the operation node contains relevant information of the modification operation of the open neural network model.
[0179] In an optional embodiment of the present invention, the method includes:
[0180] Based on the operation node list, determining an order of the at least one operation node in the operation node list;
[0181] Using the order of the operation nodes as the execution order of the modification operations corresponding to the operation nodes;
[0182] The using the operation function to perform the modification operation on the open neural network model includes:
[0183] Based on the execution order of the modification operations, the modification operations are executed using the operation functions.
[0184] In an optional embodiment of the present invention, the modification operation includes at least one of modifying the input of the open neural network model, modifying the output of the open neural network model, and modifying the computing nodes of the open neural network model.
[0185] In an optional embodiment of the present invention, the model modification tool is in communication with a preset storage device; and the parsing of the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model includes:
[0186] Parse the modified configuration file to obtain the original file path and output file path of the open neural network model in the storage device.
[0187] In an optional embodiment of the present invention, the using the operation function to perform the modification operation on the open neural network model includes:
[0188] Based on the original file path, obtaining the open neural network model from the storage device;
[0189] Parsing the open neural network model to obtain an input tensor list, an output tensor list, and a computing node tensor list of the open neural network model;
[0190] Modifying the input of the open neural network model by modifying the input tensor list;
[0191] Modifying the output of the open neural network model by modifying the output tensor list;
[0192] The computing nodes of the open neural network model are modified by modifying the computing node tensor list.
[0193] In an optional embodiment of the present invention, constructing a target open neural network model according to a modification result of the modification operation includes:
[0194] Constructing the target open neural network model according to the modified input tensor list, the modified output tensor list and the modified computing node tensor list;
[0195] The target open neural network model is stored on the storage device through the output file path.
[0196] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0197] The communication interface is used for communication between the above terminal and other devices.
[0198] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0199] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be 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, discrete hardware components.
[0200] like Figure 5 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 501 is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes a method for modifying an open neural network model described in the above embodiment.
[0201] In another embodiment provided by the present invention, a computer program product containing instructions is also provided, which, when executed on a computer, enables the computer to execute a method for modifying an open neural network model described in the above embodiment.
[0202] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0203] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0204] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0205] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for modifying an open neural network model, characterized in that: Applied to a model modification tool, the method comprises: Creating a modification configuration file of the open neural network model based on a modification target of the user for the preset open neural network model; Parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model; Determining a type of the modification operation based on the relevant information of the modification operation; Based on the type of the modification operation, configuring an operation function for executing the modification operation for the model modification tool; Using the operation function, performing the modification operation on the open neural network model; According to the modification result of the modification operation, a target open neural network model is constructed.
2. The method according to claim 1, characterized in that The parsing of the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model includes: Parse the modification configuration file to obtain an operation node list of the open neural network model; the operation node list includes at least one operation node; the operation node contains relevant information of the modification operation of the open neural network model.
3. The method according to claim 2, characterized in that The method comprises: Based on the operation node list, determining an order of the at least one operation node in the operation node list; Using the order of the operation nodes as the execution order of the modification operations corresponding to the operation nodes; The using the operation function to perform the modification operation on the open neural network model includes: Based on the execution order of the modification operations, the modification operations are executed using the operation functions.
4. The method according to claim 1, characterized in that: The modification operation includes at least one of modification of an input of the open neural network model, modification of an output of the open neural network model, and modification of a computing node of the open neural network model.
5. The method according to claim 4, characterized in that The model modification tool is in communication with a preset storage device; the parsing of the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model includes: Parse the modified configuration file to obtain the original file path and output file path of the open neural network model in the storage device.
6. The method according to claim 5, characterized in that The using the operation function to perform the modification operation on the open neural network model includes: Based on the original file path, obtaining the open neural network model from the storage device; Parsing the open neural network model to obtain an input tensor list, an output tensor list, and a computing node tensor list of the open neural network model; Modifying the input of the open neural network model by modifying the input tensor list; Modifying the output of the open neural network model by modifying the output tensor list; The computing nodes of the open neural network model are modified by modifying the computing node tensor list.
7. The method according to claim 6, characterized in that The step of constructing a target open neural network model according to the modification result of the modification operation includes: Constructing the target open neural network model according to the modified input tensor list, the modified output tensor list and the modified computing node tensor list; The target open neural network model is stored on the storage device through the output file path.
8. A device for modifying an open neural network model, characterized in that: Applied to a model modification tool, the device comprises: A creation module, used to create a modification configuration file of the open neural network model based on a modification target of the user for the preset open neural network model; A parsing module, used for parsing the modification configuration file to obtain relevant information of at least one modification operation of the open neural network model; A type determination module, used to determine the type of the modification operation based on the relevant information of the modification operation; An operation function configuration module, configured to configure an operation function for executing the modification operation for the model modification tool based on the type of the modification operation; A modification operation execution module, used to perform the modification operation on the open neural network model using the operation function; A construction module is used to construct a target open neural network model according to the modification result of the modification operation.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 7 when executing the program stored in the memory.
10. One or more computer-readable media having instructions stored thereon, which when executed by one or more processors cause the processors to perform the method according to any one of claims 1 to 7.