CN113688975A - Neural network training method and device, electronic equipment and storage medium - Google Patents

Neural network training method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113688975A
CN113688975A CN202110977534.XA CN202110977534A CN113688975A CN 113688975 A CN113688975 A CN 113688975A CN 202110977534 A CN202110977534 A CN 202110977534A CN 113688975 A CN113688975 A CN 113688975A
Authority
CN
China
Prior art keywords
processing device
preprocessing
sample image
neural network
training
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
CN202110977534.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.)
Beijing Sensetime Technology Development Co Ltd
Original Assignee
Beijing Sensetime Technology Development 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 Beijing Sensetime Technology Development Co Ltd filed Critical Beijing Sensetime Technology Development Co Ltd
Priority to CN202110977534.XA priority Critical patent/CN113688975A/en
Publication of CN113688975A publication Critical patent/CN113688975A/en
Priority to PCT/CN2022/077118 priority patent/WO2023024457A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4046Scaling of whole images or parts thereof, e.g. expanding or contracting using neural networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/60Rotation of whole images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Neurology (AREA)
  • Image Analysis (AREA)

Abstract

The invention relates to a training method, a training device, electronic equipment and a storage medium of a neural network, wherein the method is applied to first processing equipment and comprises the following steps: acquiring a sample image; sending a task instruction carrying the sample image to second processing equipment so that the second processing equipment performs at least one type of preprocessing on the sample image to obtain a target image; and receiving a task response carrying the target image and sent by the second processing device, and inputting the target image to a neural network to be trained for training. The first processing equipment transfers the task of sample image preprocessing to the second processing equipment, so that the running load of the first processing equipment can be reduced, and the training speed of the neural network is improved.

Description

Neural network training method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of neural network training technologies, and in particular, to a neural network training method and apparatus, an electronic device, and a storage medium.
Background
With the development of artificial intelligence technology, the neural network can automatically process images in multiple aspects, so that the labor cost is reduced, and the efficiency and the accuracy are improved. Before the neural network is used, a large amount of images are required to be used for training the neural network, so that the neural network can meet the requirements on the processing of the images. The massive images need to be preprocessed before being input into the neural network for training, and the preprocessing can increase the operation load of a Central Processing Unit (CPU) and reduce the training speed of the neural network.
Disclosure of Invention
The invention provides a training method and a training device for a neural network, electronic equipment and a storage medium, which are used for solving the following technical problems in the related art: the image preprocessing before the neural network training increases the operation load of the CPU and reduces the training speed of the neural network.
According to a first aspect of the embodiments of the present invention, there is provided a training method of a neural network, applied to a first processing device, the method including:
acquiring a sample image;
sending a task instruction carrying the sample image to second processing equipment so that the second processing equipment performs at least one type of preprocessing on the sample image to obtain a target image;
and receiving a task response carrying the target image and sent by the second processing device, and inputting the target image to a neural network to be trained for training.
In connection with any embodiment provided by the present disclosure, further comprising:
performing at least one pre-processing on the sample image;
the sending the task instruction carrying the sample image to a second processing device includes:
and responding to at least one preprocessing of the sample image by the first processing device, and sending a task instruction carrying the sample image to a second processing device.
In combination with any one of the embodiments provided by the present disclosure, the first processing device performs at least one preprocessing on the sample image, including:
the first processing device performs at least one preprocessing on the sample images one by one.
In combination with any embodiment provided by the present disclosure, the sending the task instruction carrying the sample image to a second processing device to enable the second processing device to perform at least one type of preprocessing on the sample image to obtain a target image includes:
and sending the task instruction carrying the first preset number of sample images to second processing equipment so that the second processing equipment uniformly performs at least one type of preprocessing on the first preset number of sample images to obtain a first preset number of target images.
In combination with any embodiment provided by the present disclosure, the sending the task instruction carrying the sample image to the second processing device includes:
and responding to the condition that the running load of the first processing equipment is higher than a preset load threshold value, and sending a task instruction carrying the sample image to second processing equipment.
In connection with any embodiment provided by the present disclosure, further comprising:
determining a running load corresponding to each preprocessing of the sample image;
and respectively determining the preprocessing type of the first processing equipment and the preprocessing type of the second processing equipment according to the operation load corresponding to each type of preprocessing.
In combination with any one of the embodiments provided by the present disclosure, the pre-processing of the sample image includes at least one of: cropping, rotation, mirroring, scaling, brightness adjustment, and contrast adjustment.
In combination with any one of the embodiments provided by the present disclosure, the inputting the target image to a neural network to be trained for training includes:
and inputting a second preset number of target images to a neural network to be trained for training.
In combination with any one of the embodiments provided by the present disclosure, the first processing device includes a CPU, and the second processing device includes a GPU
According to a second aspect of the embodiments of the present invention, there is provided a training method of a neural network, applied to a second processing device, the method including:
receiving a task instruction which is sent by first processing equipment and carries a sample image;
performing at least one preprocessing on the sample image to obtain a target image;
and sending the task response carrying the target image to the first processing equipment so that the first processing equipment inputs the target image to a neural network to be trained for training.
In combination with any embodiment provided by the present disclosure, the sample image carried by the task instruction is a sample image that is pre-processed by the first processing device.
In combination with any one of the embodiments provided by the present disclosure, the sample images carried by the task instruction are sample images of a preset number;
the at least one preprocessing is performed on the sample image to obtain a target image, and the preprocessing includes:
and uniformly performing at least one type of preprocessing on the sample images in the preset number to obtain target images in the preset number.
According to a third aspect of the embodiments of the present invention, there is provided a training apparatus for a neural network, applied to a first processing device, the apparatus including:
the acquisition module is used for acquiring a sample image;
the first sending module is used for sending the task instruction carrying the sample image to second processing equipment so that the second processing equipment can carry out at least one type of preprocessing on the sample image to obtain a target image;
and the first receiving module is used for receiving the task response carrying the target image and sent by the second processing equipment and inputting the target image to a neural network to be trained for training.
In connection with any embodiment provided by the present disclosure, further comprising:
performing at least one pre-processing on the sample image;
the sending the task instruction carrying the sample image to a second processing device includes:
and responding to at least one preprocessing of the sample image by the first processing device, and sending a task instruction carrying the sample image to a second processing device.
In combination with any one of the embodiments provided by the present disclosure, the first processing device performs at least one preprocessing on the sample image, including:
the first processing device performs at least one preprocessing on the sample images one by one.
In combination with any embodiment provided by the present disclosure, the sending the task instruction carrying the sample image to a second processing device to enable the second processing device to perform at least one type of preprocessing on the sample image to obtain a target image includes:
and sending the task instruction carrying the first preset number of sample images to second processing equipment so that the second processing equipment uniformly performs at least one type of preprocessing on the first preset number of sample images to obtain a first preset number of target images.
In combination with any embodiment provided by the present disclosure, the sending the task instruction carrying the sample image to the second processing device includes:
and responding to the condition that the running load of the first processing equipment is higher than a preset load threshold value, and sending a task instruction carrying the sample image to second processing equipment.
In connection with any embodiment provided by the present disclosure, further comprising:
determining a running load corresponding to each preprocessing of the sample image;
and respectively determining the preprocessing type of the first processing equipment and the preprocessing type of the second processing equipment according to the operation load corresponding to each type of preprocessing.
In combination with any one of the embodiments provided by the present disclosure, the pre-processing of the sample image includes at least one of: cropping, rotation, mirroring, scaling, brightness adjustment, and contrast adjustment.
In combination with any one of the embodiments provided by the present disclosure, the inputting the target image to a neural network to be trained for training includes:
and inputting a second preset number of target images to a neural network to be trained for training.
In connection with any embodiment provided by the disclosure, the first processing device includes a CPU and the second processing device includes a GPU.
According to a fourth aspect of the embodiments of the present invention, there is provided an apparatus for training a neural network, applied to a second processing device, the apparatus including:
the second receiving module is used for receiving a task instruction which is sent by the first processing equipment and carries the sample image;
the preprocessing module is used for carrying out at least one type of preprocessing on the sample image to obtain a target image;
and the second sending module is used for sending the task response carrying the target image to the first processing equipment so as to enable the first processing equipment to input the target image to a neural network to be trained for training.
In combination with any embodiment provided by the present disclosure, the sample image carried by the task instruction is a sample image that is pre-processed by the first processing device.
In combination with any one of the embodiments provided by the present disclosure, the sample images carried by the task instruction are sample images of a preset number;
the at least one preprocessing is performed on the sample image to obtain a target image, and the preprocessing includes: and uniformly performing at least one type of preprocessing on the sample images in the preset number to obtain target images in the preset number.
According to a fifth aspect of embodiments of the present invention, there is provided an electronic device, the device comprising a memory for storing computer instructions executable on a processor, the processor being configured to implement the method of the first or second aspect when executing the computer instructions.
According to a sixth aspect of embodiments of the present invention, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of the first or second aspect.
According to the embodiment, a sample image is obtained through a first processing device, a task instruction carrying the sample image is sent to a second processing device, so that the second processing device performs at least one type of preprocessing on the sample image to obtain a target image, and finally the first processing device receives a task response carrying the target image sent by the second processing device and inputs the target image to a neural network to be trained for training. The first processing equipment transfers the task of sample image preprocessing to the second processing equipment, so that the running load of the first processing equipment can be reduced, and the training speed of the neural network is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a flow chart illustrating a method of training a neural network according to an embodiment of the present invention;
FIG. 2 is a process diagram of a method for training a neural network according to an embodiment of the present invention;
FIG. 3 is a flow chart of a neural network training method according to an embodiment of the present invention
FIG. 4 is a schematic structural diagram of a training apparatus for a neural network according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a training apparatus for a neural network according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present invention. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
In a first aspect, at least one embodiment of the present invention provides a method for training a neural network, please refer to fig. 1, which illustrates a flow of the method, including steps S101 to S103.
Wherein the training method may be applied to a first processing device, such as a CPU. The first processing device may be a processing device in an electronic device such as a terminal device or a server. The terminal device may be a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a Personal Digital Assistant (PDA) handheld device, a computing device, a vehicle-mounted device, a wearable device, and the like, and the server may be a local server, a cloud server, and the like.
The memory of the electronic device where the first processing device is located stores a framework model for neural network training in advance, and the framework model may include a dataloader module, a transform module, a training module, and the like. The framework model may be in the form of computer readable instructions, so that the first processing device may read the instructions of the framework model to perform the training method.
The neural network aimed by the training method can be a neural network used for detecting key points of the human face.
In step S101, a sample image is acquired.
The first processing device can complete the acquisition of the image through the data loading module. For example, the first processing device may read code instructions of a data loading module in the memory, so that the function of the loading module, i.e. loading a sample image that is previously input and stored in the memory, may be performed.
It should be noted that the amount of sample images that are input in advance and stored in the memory is large, and therefore, when the sample images are acquired in this step, the sample images may be acquired one by one or may be acquired in batch.
The sample images are images in a training set used to train the neural network. The sample images are all marked with labels, the labels are training references of the sample images, namely the training process is that the prediction result of the neural network is expected to approach the labels infinitely. Therefore, this step can acquire the label of the sample image at the same time as acquiring the sample image.
In step S102, a task instruction carrying the sample image is sent to a second processing device, so that the second processing device performs at least one type of preprocessing on the sample image to obtain a target image.
The task instruction is used for instructing the second processing device to pre-process the sample image carried by the second processing device, and the task instruction can also instruct the type, the sequence and the like of the pre-processing. The second processing device receiving the task instruction may read a code instruction of the preprocessing module stored in the memory according to the direction and execute a function of the preprocessing module, i.e., a preprocessing function, on the second processing device. It is understood that in the neural network trained framework model pre-stored in the memory, the functional relationship, parameters and the like of the code instructions read and executed by the first processing device are adapted to the first processing device, and the functional relationship, parameters and the like of the code instructions read and executed by the second processing device are adapted to the second processing device.
The second processing device may be a GPU (graphics processing unit), which has the capability of parallel processing, and thus has a faster preprocessing speed for images. Therefore, the first processing device may carry a first preset number of sample images in the task instruction, and send the task instruction carrying the first preset number of sample images to the second processing device, so that the second processing device performs at least one type of preprocessing on the first preset number of sample images uniformly to obtain a first preset number of target images. That is, the first processing device may send the sample images in batches, and the corresponding second processing device may perform batch pre-processing on the sample images.
Optionally, when the operating load of the first processing device is higher than a preset load threshold, the first processing device sends the task instruction carrying the sample image to the second processing device. When the operation load of the first processing device is lower than or equal to the preset load threshold value, the first processing device does not send a task instruction to the second processing device, and the sample image is preprocessed by the first processing device. The first processing device may detect its operating load in real time during operation, which may be in the form of a percentage of full load, so the load threshold may be preset to 60%, 70%, 80%, etc.
In the above case, the preprocessing module in the neural network trained framework model pre-stored in the memory has code instructions adapted to the first processing device and code instructions adapted to the second processing device, the first processing device performs the preprocessing function by reading the code instructions adapted thereto, and the second processing device performs the preprocessing function by reading the code instructions adapted thereto.
The preprocessing of the sample image comprises at least one of: cropping, rotation, mirroring, scaling, brightness adjustment, and contrast adjustment.
In step S103, a task response carrying the target image and sent by the second processing device is received, and the target image is input to a neural network to be trained for training.
After the second processing device finishes preprocessing the sample image to obtain the target image, the task response carrying the target image is sent to the first processing device, and then the first processing device receives the task response carrying the target image sent by the second processing device. When the second processing device pre-processes the sample images in batch, the task response may carry the batch of sample images that have been pre-processed, that is, the batch is returned to the first processing device.
Optionally, a second preset number of the target images are input to a neural network to be trained for training. After the sample image is input into the neural network, the neural network outputs a predicted value, then a network loss value is determined through the predicted value and a label of the sample image, and finally parameters of the neural network are adjusted according to the network loss value until convergence.
According to the embodiment, a sample image is obtained through a first processing device, a task instruction carrying the sample image is sent to a second processing device, so that the second processing device performs at least one type of preprocessing on the sample image to obtain a target image, and finally the first processing device receives a task response carrying the target image sent by the second processing device and inputs the target image to a neural network to be trained for training. The first processing equipment transfers the task of sample image preprocessing to the second processing equipment, so that the running load of the first processing equipment can be reduced, and the training speed of the neural network is improved.
In some embodiments of the present disclosure, after obtaining a sample image, a first processing device may perform at least one type of preprocessing on the sample image, and then send a task instruction carrying the sample image to a second processing device in response to the sample image being subjected to the at least one type of preprocessing by the first processing device. That is, the first processing device performs a partial preprocessing operation on the sample image, and then sends the sample image to the second processing device, and then the second processing device performs the remaining preprocessing operation.
When the first processing device is a CPU, the first processing device may perform at least one type of preprocessing on the sample images one by one. The preprocessing of each sample image is carried out in a subprocess, and the subprocess is used for loading the sample image, preprocessing the sample image, adjusting the sample image into a tensor format, and then returning the preprocessed and format-adjusted sample image to the main process. Therefore, when the first processing device preprocesses the sample images, the main process can accumulate the preprocessed sample images, when the accumulated number reaches a first preset number, the accumulated sample images can be sent to the second processing device in batch in a form carried by the task instruction, and the second processing device can uniformly perform at least one type of preprocessing on the batch of sample images to obtain target images in the first preset number.
In the above embodiment, the first processing device and the second processing device respectively perform part of the preprocessing operations, so that all the preprocessing operations need to be split in advance.
The kind of pretreatment of the first and second treatment apparatuses may be determined in the following manner: firstly, determining the operation load corresponding to each preprocessing of the sample image; and then, respectively determining the preprocessing type of the first processing equipment and the preprocessing type of the second processing equipment according to the operation load corresponding to each type of preprocessing.
When the first processing device determines the operation load corresponding to a certain type of preprocessing, all preprocessing operations may be executed on the first processing device and the operation load may be recorded, then the preprocessing is removed, the remaining preprocessing operations are executed and the operation load is recorded, and then the operation load difference between the two cases may be determined as the operation load corresponding to the preprocessing.
When the preprocessing type of the first processing device and the preprocessing type of the second processing device are determined, preprocessing with larger operation load can be distributed to the second processing device, so that the operation load of the first processing device is reduced to the greatest extent, and the training speed of the neural network is improved.
In one example, the pre-processing performed by the first processing device includes at least one of scaling, brightness adjustment, and contrast adjustment, and the pre-processing performed by the second processing device includes at least one of clipping, rotation, and mirroring.
In addition, when determining the kind of preprocessing by the first processing device and the kind of preprocessing by the second processing device, a plurality of preprocessing allocation schemes can be determined, that is, an allocation scheme that is not fixed. The determined plurality of pre-processing allocation schemes may be associated with an operating load of the first processing device.
A plurality of load thresholds may be set, each load threshold corresponding to an allocation scheme, and then when the operating load of the first processing device is higher than a certain load threshold (and lower than the last load threshold adjacent to the load threshold), the allocation scheme corresponding to the load threshold is used. For example, the load thresholds may be set to 60%, 70%, and 80% of the full load, and then, of the three load thresholds, the running load allocated to the preprocessing operation executed by the second processing device is the lowest in the allocation scheme corresponding to 60%, and the running load allocated to the preprocessing operation executed by the second processing device is the highest in the allocation scheme corresponding to 80%.
Referring to fig. 2, a process example of the neural network training method provided by the present invention is shown. As can be seen from the figure, the subprocess operated by the CPU loads the sample image, then performs the first part of preprocessing, converts the sample image into a tensor format, then returns the sample image subjected to preprocessing and format conversion to the main process, the main process sends the sample image to the GPU for the second part of preprocessing, the GPU returns the sample image subjected to the second part of preprocessing to the CPU, and the CPU trains the neural network by using the sample image.
In a second aspect, at least one embodiment of the invention provides a method for training a neural network, please refer to fig. 3, which illustrates a flow of the method, including steps S301 to S303.
Wherein the training method may be applied to a second processing device, such as a GPU. The second processing device may be a processing device in an electronic device such as a terminal device or a server. The terminal device may be a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a Personal Digital Assistant (PDA) handheld device, a computing device, a vehicle-mounted device, a wearable device, and the like, and the server may be a local server, a cloud server, and the like.
The memory of the electronic device where the second processing device is located stores a framework model for neural network training in advance, and the framework model may include a dataloader module, a transform module, a training module, and the like. The framework model may be in the form of computer readable instructions, so that the second processing device may read the instructions of the framework model to perform the training method.
In step S301, a task instruction carrying a sample image sent by a first processing device is received.
The first processing device may be a CPU, and the first processing device may read a code instruction of a data loading module of the neural network trained framework model stored in advance in the memory, so as to perform a function of loading data, and obtain a sample image. And then carrying the sample image in a task instruction and sending the task instruction to a second processing device.
The sample images are images in a training set used to train the neural network. The sample images are all marked with labels, the labels are training references of the sample images, namely the training process is that the prediction result of the neural network is expected to approach the labels infinitely. Therefore, this step can acquire the label of the sample image at the same time as acquiring the sample image.
In one example, the first processing device may carry a first preset number of sample images within the task instruction, and send the task instruction carrying the first preset number of sample images to the second processing device.
In step S302, at least one kind of preprocessing is performed on the sample image to obtain a target image.
The task instruction is used for instructing the second processing device to pre-process the sample image carried by the second processing device, and the task instruction can also instruct the type, the sequence and the like of the pre-processing. The second processing device receiving the task instruction may read a code instruction of the preprocessing module stored in the memory according to the direction and execute a function of the preprocessing module, i.e., a preprocessing function, on the second processing device. It is understood that in the neural network trained framework model pre-stored in the memory, the functional relationship, parameters and the like of the code instructions read and executed by the first processing device are adapted to the first processing device, and the functional relationship, parameters and the like of the code instructions read and executed by the second processing device are adapted to the second processing device.
When the sample images carried by the task instruction are the sample images of the first preset number, at least one type of preprocessing can be uniformly performed on the sample images of the first preset number to obtain target images of the preset number. The GPU has the capability of parallel processing, so that batch preprocessing can be performed on the sample images, and the preprocessing speed of the sample images is high.
The preprocessing of the sample image comprises at least one of: cropping, rotation, mirroring, scaling, brightness adjustment, and contrast adjustment.
In step S303, a task response carrying the target image is sent to the first processing device, so that the first processing device inputs the target image to a neural network to be trained for training.
After the second processing device finishes preprocessing the sample image to obtain the target image, the task response carrying the target image is sent to the first processing device, and then the first processing device receives the task response carrying the target image sent by the second processing device. When the second processing device pre-processes the sample images in batch, the task response may carry the batch of sample images that have been pre-processed, that is, the batch is returned to the first processing device.
Optionally, the first processing device may input a second preset number of target images to the neural network to be trained for training. After the sample image is input into the neural network, the neural network outputs a predicted value, then a network loss value is determined through the predicted value and a label of the sample image, and finally parameters of the neural network are adjusted according to the network loss value until convergence.
According to the embodiment, the task instruction which is sent by the first processing device and carries the sample image is received, at least one type of preprocessing is carried out on the sample image to obtain the target image, and finally the task response carrying the target image is sent to the first processing device, so that the first processing device inputs the target image to the neural network to be trained to carry out training. The first processing equipment transfers the task of sample image preprocessing to the second processing equipment, so that the running load of the first processing equipment can be reduced, and the training speed of the neural network is improved.
In combination with any embodiment provided by the present disclosure, the sample image carried by the task instruction is a sample image that is pre-processed by the first processing device.
After obtaining a sample image, a first processing device may perform at least one type of preprocessing on the sample image, and then send a task instruction carrying the sample image to a second processing device in response to the sample image being subjected to the at least one type of preprocessing by the first processing device. That is, the first processing device performs a partial preprocessing operation on the sample image, and then sends the sample image to the second processing device, and then the second processing device performs the remaining preprocessing operation.
When the first processing device is a CPU, the first processing device may perform at least one type of preprocessing on the sample images one by one. And the first processing equipment can accumulate the preprocessed sample images while preprocessing the sample images, when the accumulated number reaches a first preset number, the accumulated sample images can be sent to the second processing equipment in batch in a form carried by the task instruction, and the second processing equipment can uniformly perform at least one type of preprocessing on the batch of sample images to obtain target images in the first preset number.
According to a third aspect of the embodiments of the present invention, there is provided a training apparatus for neural network, applied to a first processing device, referring to fig. 4, which shows a structure of the apparatus, the apparatus includes:
an obtaining module 401, configured to obtain a sample image;
a first sending module 402, configured to send a task instruction carrying the sample image to a second processing device, so that the second processing device performs at least one type of preprocessing on the sample image to obtain a target image;
a first receiving module 403, configured to receive a task response carrying the target image sent by the second processing device, and input the target image to a neural network to be trained for training.
In some embodiments of the present disclosure, further comprising:
performing at least one pre-processing on the sample image;
the sending the task instruction carrying the sample image to a second processing device includes:
and responding to at least one preprocessing of the sample image by the first processing device, and sending a task instruction carrying the sample image to a second processing device.
In some embodiments of the present disclosure, the first processing device performs at least one pre-processing on the sample image, including:
the first processing device performs at least one preprocessing on the sample images one by one.
In combination with any embodiment provided by the present disclosure, the sending the task instruction carrying the sample image to a second processing device to enable the second processing device to perform at least one type of preprocessing on the sample image to obtain a target image includes:
and sending the task instruction carrying the first preset number of sample images to second processing equipment so that the second processing equipment uniformly performs at least one type of preprocessing on the first preset number of sample images to obtain a first preset number of target images.
In some embodiments of the present disclosure, the sending the task instruction carrying the sample image to the second processing device includes:
and responding to the condition that the running load of the first processing equipment is higher than a preset load threshold value, and sending a task instruction carrying the sample image to second processing equipment.
In some embodiments of the present disclosure, further comprising:
determining a running load corresponding to each preprocessing of the sample image;
and respectively determining the preprocessing type of the first processing equipment and the preprocessing type of the second processing equipment according to the operation load corresponding to each type of preprocessing.
In some embodiments of the present disclosure, the pre-processing of the sample image comprises at least one of: cropping, rotation, mirroring, scaling, brightness adjustment, and contrast adjustment.
In some embodiments of the present disclosure, the inputting the target image to a neural network to be trained for training includes:
and inputting a second preset number of target images to a neural network to be trained for training.
In some embodiments of the disclosure, the first processing device comprises a CPU and the second processing device comprises a GPU.
According to a fourth aspect of the embodiments of the present invention, there is provided a training apparatus for neural networks, which is applied to a second processing device, and referring to fig. 5, it shows a structure of the apparatus, and the apparatus includes:
a second receiving module 501, configured to receive a task instruction carrying a sample image and sent by a first processing device;
a preprocessing module 502, configured to perform at least one type of preprocessing on the sample image to obtain a target image;
a second sending module 503, configured to send a task response carrying the target image to the first processing device, so that the first processing device inputs the target image to a neural network to be trained for training.
In some embodiments of the present disclosure, the sample image carried by the task instruction is a sample image that has undergone at least one preprocessing by the first processing device.
In some embodiments of the present disclosure, the sample images carried by the task instruction are a preset number of sample images;
the at least one preprocessing is performed on the sample image to obtain a target image, and the preprocessing includes: and uniformly performing at least one type of preprocessing on the sample images in the preset number to obtain target images in the preset number.
With regard to the apparatus in the above embodiments, the specific manner in which the respective modules perform operations has been described in detail in the embodiments of the first aspect and the second aspect related to the method, and will not be elaborated here.
In a fifth aspect, at least one embodiment of the invention provides an electronic device, please refer to fig. 6, which shows a structure of the device, the device includes a memory for storing computer instructions executable on a processor, and the processor is configured to train a neural network based on the method of the first aspect or the second aspect when executing the computer instructions.
In a sixth aspect, at least one embodiment of the invention provides a computer readable storage medium having a computer program stored thereon, which when executed by a processor, performs the method of the first aspect or the method of the second aspect.
In the present invention, the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. The term "plurality" means two or more unless expressly limited otherwise.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (16)

1. A training method of a neural network, applied to a first processing device, the method comprising:
acquiring a sample image;
sending a task instruction carrying the sample image to second processing equipment so that the second processing equipment performs at least one type of preprocessing on the sample image to obtain a target image;
and receiving a task response carrying the target image and sent by the second processing device, and inputting the target image to a neural network to be trained for training.
2. The method of training a neural network of claim 1, further comprising:
performing at least one pre-processing on the sample image;
the sending the task instruction carrying the sample image to a second processing device includes:
and responding to at least one preprocessing of the sample image by the first processing device, and sending a task instruction carrying the sample image to a second processing device.
3. The method of claim 2, wherein the first processing device performs at least one preprocessing on the sample image, comprising:
the first processing device performs at least one preprocessing on the sample images one by one.
4. The training method of the neural network according to claim 2 or 3, wherein the sending the task instruction carrying the sample image to a second processing device to make the second processing device perform at least one type of preprocessing on the sample image to obtain a target image comprises:
and sending the task instruction carrying the first preset number of sample images to second processing equipment so that the second processing equipment uniformly performs at least one type of preprocessing on the first preset number of sample images to obtain a first preset number of target images.
5. The training method of the neural network according to any one of claims 1 to 4, wherein the sending of the task instruction carrying the sample image to the second processing device includes:
and responding to the condition that the running load of the first processing equipment is higher than a preset load threshold value, and sending a task instruction carrying the sample image to second processing equipment.
6. The training method of a neural network according to any one of claims 1 to 5, further comprising:
determining a running load corresponding to each preprocessing of the sample image;
and respectively determining the preprocessing type of the first processing equipment and the preprocessing type of the second processing equipment according to the operation load corresponding to each type of preprocessing.
7. The method of training a neural network of any one of claims 1 to 6, wherein the preprocessing of the sample image includes at least one of: cropping, rotation, mirroring, scaling, brightness adjustment, and contrast adjustment.
8. The method for training the neural network according to any one of claims 1 to 7, wherein the inputting the target image into the neural network to be trained for training comprises:
and inputting a second preset number of target images to a neural network to be trained for training.
9. The training method for the neural network according to any one of claims 1 to 8, wherein the first processing device includes a CPU and the second processing device includes a GPU.
10. A training method of a neural network, applied to a second processing device, the method comprising:
receiving a task instruction which is sent by first processing equipment and carries a sample image;
performing at least one preprocessing on the sample image to obtain a target image;
and sending the task response carrying the target image to the first processing equipment so that the first processing equipment inputs the target image to a neural network to be trained for training.
11. The method for training a neural network according to claim 10, wherein the sample image carried by the task instruction is at least one pre-processed sample image processed by the first processing device.
12. The training method of the neural network according to claim 10 or 11, wherein the sample images carried by the task instruction are a preset number of sample images;
the at least one preprocessing is performed on the sample image to obtain a target image, and the preprocessing includes:
and uniformly performing at least one type of preprocessing on the sample images in the preset number to obtain target images in the preset number.
13. An apparatus for training a neural network, applied to a first processing device, the apparatus comprising:
the acquisition module is used for acquiring a sample image;
the first sending module is used for sending the task instruction carrying the sample image to second processing equipment so that the second processing equipment can carry out at least one type of preprocessing on the sample image to obtain a target image;
and the first receiving module is used for receiving the task response carrying the target image and sent by the second processing equipment and inputting the target image to a neural network to be trained for training.
14. An apparatus for training a neural network, applied to a second processing device, the apparatus comprising:
the second receiving module is used for receiving a task instruction which is sent by the first processing equipment and carries the sample image;
the preprocessing module is used for carrying out at least one type of preprocessing on the sample image to obtain a target image;
and the second sending module is used for sending the task response carrying the target image to the first processing equipment so as to enable the first processing equipment to input the target image to a neural network to be trained for training.
15. An electronic device, comprising a memory for storing computer instructions executable on a processor, the processor being configured to implement the method of any one of claims 1 to 12 when executing the computer instructions.
16. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method of any one of claims 1 to 12.
CN202110977534.XA 2021-08-24 2021-08-24 Neural network training method and device, electronic equipment and storage medium Pending CN113688975A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110977534.XA CN113688975A (en) 2021-08-24 2021-08-24 Neural network training method and device, electronic equipment and storage medium
PCT/CN2022/077118 WO2023024457A1 (en) 2021-08-24 2022-02-21 Method and apparatus for training neural network, electronic device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110977534.XA CN113688975A (en) 2021-08-24 2021-08-24 Neural network training method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113688975A true CN113688975A (en) 2021-11-23

Family

ID=78582122

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110977534.XA Pending CN113688975A (en) 2021-08-24 2021-08-24 Neural network training method and device, electronic equipment and storage medium

Country Status (2)

Country Link
CN (1) CN113688975A (en)
WO (1) WO2023024457A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023024457A1 (en) * 2021-08-24 2023-03-02 上海商汤智能科技有限公司 Method and apparatus for training neural network, electronic device, and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105980987A (en) * 2014-01-29 2016-09-28 三星电子株式会社 Task scheduling method and apparatus
CN108416440A (en) * 2018-03-20 2018-08-17 上海未来伙伴机器人有限公司 A kind of training method of neural network, object identification method and device
CN109636819A (en) * 2018-12-17 2019-04-16 郑州云海信息技术有限公司 A kind of Lung neoplasm growth rate prediction meanss based on deep learning
WO2020098158A1 (en) * 2018-11-14 2020-05-22 平安科技(深圳)有限公司 Pedestrian re-recognition method and apparatus, and computer readable storage medium
CN111368923A (en) * 2020-03-05 2020-07-03 上海商汤智能科技有限公司 Neural network training method and device, electronic equipment and storage medium
CN111625080A (en) * 2020-05-22 2020-09-04 苏州浪潮智能科技有限公司 Server energy saving method and device, electronic equipment and storage medium
CN111930518A (en) * 2020-09-22 2020-11-13 北京东方通科技股份有限公司 Knowledge graph representation learning-oriented distributed framework construction method
CN111985635A (en) * 2020-09-02 2020-11-24 北京小米松果电子有限公司 Method, device and medium for accelerating neural network inference processing
WO2020259416A1 (en) * 2019-06-28 2020-12-30 商汤集团有限公司 Image collection control method and apparatus, electronic device, and storage medium
US20210133572A1 (en) * 2019-11-06 2021-05-06 Korea Institute Of Science And Technology Image analysis apparatus using machine learning-based artificial intelligence including preprocessing modules

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11551095B2 (en) * 2018-10-25 2023-01-10 Runai Labs Ltd. Sharing preprocessing, computations, and hardware resources between multiple neural networks
CN110738148A (en) * 2019-09-29 2020-01-31 浙江新再灵科技股份有限公司 Cloud target detection algorithm based on heterogeneous platform
CN110796242A (en) * 2019-11-01 2020-02-14 广东三维家信息科技有限公司 Neural network model reasoning method and device, electronic equipment and readable medium
CN112308096A (en) * 2020-11-02 2021-02-02 得遇科技(杭州)有限责任公司 Image recognition method and device, computer equipment and storage medium
CN113688975A (en) * 2021-08-24 2021-11-23 北京市商汤科技开发有限公司 Neural network training method and device, electronic equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105980987A (en) * 2014-01-29 2016-09-28 三星电子株式会社 Task scheduling method and apparatus
CN108416440A (en) * 2018-03-20 2018-08-17 上海未来伙伴机器人有限公司 A kind of training method of neural network, object identification method and device
WO2020098158A1 (en) * 2018-11-14 2020-05-22 平安科技(深圳)有限公司 Pedestrian re-recognition method and apparatus, and computer readable storage medium
CN109636819A (en) * 2018-12-17 2019-04-16 郑州云海信息技术有限公司 A kind of Lung neoplasm growth rate prediction meanss based on deep learning
WO2020259416A1 (en) * 2019-06-28 2020-12-30 商汤集团有限公司 Image collection control method and apparatus, electronic device, and storage medium
US20210133572A1 (en) * 2019-11-06 2021-05-06 Korea Institute Of Science And Technology Image analysis apparatus using machine learning-based artificial intelligence including preprocessing modules
CN111368923A (en) * 2020-03-05 2020-07-03 上海商汤智能科技有限公司 Neural network training method and device, electronic equipment and storage medium
CN111625080A (en) * 2020-05-22 2020-09-04 苏州浪潮智能科技有限公司 Server energy saving method and device, electronic equipment and storage medium
CN111985635A (en) * 2020-09-02 2020-11-24 北京小米松果电子有限公司 Method, device and medium for accelerating neural network inference processing
CN111930518A (en) * 2020-09-22 2020-11-13 北京东方通科技股份有限公司 Knowledge graph representation learning-oriented distributed framework construction method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023024457A1 (en) * 2021-08-24 2023-03-02 上海商汤智能科技有限公司 Method and apparatus for training neural network, electronic device, and storage medium

Also Published As

Publication number Publication date
WO2023024457A1 (en) 2023-03-02

Similar Documents

Publication Publication Date Title
US11790632B2 (en) Method and apparatus for sample labeling, and method and apparatus for identifying damage classification
CN110929865B (en) Network quantification method, service processing method and related product
CN110956202B (en) Image training method, system, medium and intelligent device based on distributed learning
EP3855362A1 (en) Convolution processing method, apparatus, and storage medium of convolutional neural network
CN111104954B (en) Object classification method and device
US20210064919A1 (en) Method and apparatus for processing image
CN111104988B (en) Image recognition method and related device
CN115794913B (en) Data processing method and device in artificial intelligence system
CN114945817A (en) Task processing method, device and equipment based on defect detection and storage medium
CN108288064B (en) Method and device for generating pictures
CN113688975A (en) Neural network training method and device, electronic equipment and storage medium
CN111564206A (en) Diagnosis method, device, equipment and medium
EP4365755A1 (en) Method for identifying clarity of well logging image, apparatus, medium, and electronic device
CN116912556A (en) Picture classification method and device, electronic equipment and storage medium
CN115115530B (en) Image deblurring method, device, terminal equipment and medium
CN111833232A (en) Image processing device
CN111563464B (en) Image processing method, device, computing equipment and medium
CN112581001B (en) Evaluation method and device of equipment, electronic equipment and readable storage medium
CN113988316A (en) Method and device for training machine learning model
CN113962955A (en) Method and device for identifying target object from image and electronic equipment
CN114004974A (en) Method and device for optimizing images shot in low-light environment
CN111815658B (en) Image recognition method and device
CN112288748B (en) Semantic segmentation network training and image semantic segmentation method and device
CN109344836B (en) Character recognition method and equipment
CN114187593B (en) Image processing method and device

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40053987

Country of ref document: HK