Specific embodiment
Below in conjunction with attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete
Ground describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.Usually exist
The component of the embodiment of the present invention described and illustrated in attached drawing can configure to arrange and design with a variety of herein.Cause
This, the detailed description of the embodiment of the present invention to providing in the accompanying drawings is not intended to limit claimed invention below
Scope, but it is merely representative of the selected embodiment of the present invention.Based on the embodiment of the present invention, those skilled in the art are not doing
Go out all other embodiments obtained on the premise of creative work, belong to the scope of protection of the invention.
Machine learning is the important step of artificial intelligence, and application is very extensive.In correlation technique, have mobile terminal
There is machine learning functionality, it is necessary to which a machine learning initial model is first selected to be trained the corresponding a large amount of model parameters of acquisition, then
Machine learning model with a large amount of model parameters is stored in mobile terminal.In machine learning function in use, passing through tune
It is realized with corresponding model parameter.Typically, the precision that machine learning function is realized depends on model parameter, preferable machine
The corresponding model parameter quantity of device learning functionality is huge.In order to ensure model parameter can be by normal use, above-mentioned model ginseng
Number is needed for float real-coded GAs.But byte shared by single float real-coded GAs is four bytes, therefore, preferable machine
Memory space shared by device learning functionality is bigger, when being stored in mobile terminal, system resource is occupied greatly, directly affects user
Experience, is unfavorable for applying in mobile terminal.Therefore, the embodiment of the present invention provides a kind of model parameter processing method, device, electricity
Sub- terminal and storage medium, to overcome the limitation that machine learning function is applied in the terminal.
Fig. 1 shows the block diagram for the electronic equipment 100 that present pre-ferred embodiments provide.Electronic equipment 100 is preferred
For mobile terminal device, such as smart mobile phone, tablet computer, pocket computer on knee, vehicle-mounted computer, a number can be included
Word assistant (personal digital assistant, PDA), wearable mobile terminal etc..The electronic equipment 100 includes
Model parameter processing unit 200, memory 101, storage control 102, processor 103.
The memory 101, storage control 102,103 each element of processor directly or indirectly electrically connect between each other
It connects, to realize the transmission of data or interaction.For example, these elements can pass through one or more communication bus or signal between each other
Line, which is realized, to be electrically connected.The model parameter processing unit 200 include it is at least one can be with software or firmware (firmware)
Form be stored in the memory 101 or be solidificated in the electronic equipment 100 operating system (operating system,
OS the software function module in).The processor 103 is used to perform the executable module stored in memory 101, such as described
The software function module or computer program that model parameter processing unit 200 includes.
Wherein, memory 101 may be, but not limited to, random access memory (Random Access Memory,
RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only
Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM),
Electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only Memory, EEPROM) etc..
Wherein, memory 101 is for storing program, and the processor 103 performs described program, this hair after receiving and executing instruction
Method performed by the server for the flow definition that bright any embodiment discloses can be applied in processor 103 or by
Reason device 103 is realized.
Processor 103 can be a kind of IC chip, have signal handling capacity.Above-mentioned processor 103 can be with
It is general processor, including central processing unit (Central Processing Unit, CPU), network processing unit (Network
Processor, NP), speech processor and video processor etc.;Can also be digital signal processor, application-specific integrated circuit,
Field programmable gate array either other programmable logic device, discrete gate or transistor logic, discrete hardware components.
It can realize or perform disclosed each method, step and the logic diagram in the embodiment of the present invention.General processor can be
Microprocessor or the processor 103 can also be any conventional processors etc..
First embodiment
It please refers to Fig.2, Fig. 2 is a kind of step flow for model parameter processing method that present pre-ferred embodiments provide
Figure.The method may include following steps:
Step S101 according to pending model, obtains the corresponding parameter sets to be compressed of the pending model.
Above-mentioned pending model can carry out the model parameter file generated after machine learning functional training.Above-mentioned model
Parameter File can include multiple model parameters.
For better compression effectiveness, above-mentioned pending model can be by the model of model pruning modes after training.
In embodiments of the present invention, above-mentioned parameter sets to be compressed are model parameter collection corresponding with pending model.On
It can be a set or multiple set to state parameter sets to be compressed.Include at least in each parameter sets to be compressed
The corresponding model parameter of two pending models.As a kind of embodiment, as shown in figure 3, obtaining the pending model pair
The step of parameter sets to be compressed answered, can include:
Sub-step S1011 obtains the first model parameter of parameter values maximum in the corresponding model parameter of pending model
And the second model parameter of parameter values minimum.
In embodiments of the present invention, the corresponding model parameter of pending model is sequentially placed into array, using inquiry language
The parameter values that sentence obtains the first model parameter and the second model parameter degree is less than.
As a kind of embodiment, following query statement may be employed:
F_max=A [0];
F_min=A [0];
For (inti=0;i<n;++i)
{
If(f_max<A[i])
{
F_max=A [i];
}
Else if(f_min>A[i])
{
F_min=A [i];
}
}
Above-mentioned f_max represents the parameter values of the first model parameter, will be arranged in primary model in array first
The parameter values of parameter assign f_max, by f_max successively compared with the parameter values of each model parameter in array.
When occurring being more than the f_max model parameters, the model parameter is changed to by the value of f_max, continues to repeat to compare, until
The comparison with the last one model parameter in array is completed, with the parameter values of the value of f_max the first model parameter the most.On
The parameter values that f_min represents the second model parameter are stated, first by the parameter for being arranged in primary model parameter in array
Numerical value assigns f_min, by f_min successively compared with the parameter values of each model parameter in array.When being less than
During the f_min model parameters, the value of f_min is changed to the model parameter, continues to repeat to compare, until in completion and array
The comparison of the last one model parameter, with the parameter values of the value of f_min the second model parameter the most.
Sub-step S1012, when the difference between the difference between above-mentioned first model parameter and the second model parameter is more than
During default first threshold, piecemeal is carried out to the pending model according to pre-defined rule, to obtain pending submodel.
In the present embodiment, above-mentioned pending submodule can be a part for pending module, by pending module pair
The model parameter answered is divided into multiple parameters matrix.By division, to ensure that the model included by each pending submodule is joined
Difference in number between the model parameter of the model parameter of parameter values maximum and parameter values minimum is less than first threshold.
As a kind of embodiment, above-mentioned first threshold can be 63335.
Sub-step S1013 is based respectively on the corresponding model parameter of each pending submodel and establishes a corresponding institute
State parameter sets to be compressed.
In embodiments of the present invention, established respectively according to the corresponding model parameter of each pending submodel and corresponding wait to press
Contracting parameter sets, to obtain multiple parameter sets to be compressed.It should be noted that parameter values in each parameter sets to be compressed
Difference between the 3rd maximum model parameter and the 4th model parameter of parameter values minimum is respectively less than first threshold.When waiting to locate
When managing model and only corresponding to a parameter sets to be compressed, then corresponding 3rd model parameter of the parameter sets to be compressed is to wait to locate
Corresponding first model parameter of model is managed, corresponding 4th model parameter of the parameter sets to be compressed is that pending model corresponds to
The second model parameter.
Sub-step S1014, when the difference between first model parameter and the second model parameter is no more than described first
During threshold value, the corresponding parameter sets to be compressed are established based on the corresponding model parameter of the pending model.
In embodiments of the present invention, coordination is belonged between sub-step S1014 and step S1012, there is no absolute
Sequencing.When the difference between first model parameter and the second model parameter is no more than the first threshold, then directly
It connects and establishes a parameter sets to be compressed with the corresponding all model parameters of pending model.
, can be excessive to avoid the difference between model parameter by above-mentioned steps in the present embodiment, cause compressed mould
Shape parameter distortion.
Step S102 according to the model parameter in the parameter sets to be compressed, determines Compression Strategies.
Above-mentioned Compression Strategies can include the first strategy and the second strategy.
Above-mentioned first strategy is used to be converted to the model parameter storage parameter of no character type.Above-mentioned no character type
Data only account for a byte, therefore, can be by master mould compression of parameters to a quarter using the second strategy.Specifically, select
Each model parameter is mapped as the depositing without character type less than pre-set second threshold by default corresponding mapping function
Store up data.
Above-mentioned second strategy is used to be converted to the model parameter storage data of short.The data of above-mentioned short
Two bytes are accounted for, it therefore, can be by master mould compression of parameters to half using the second strategy.Specifically, select default
Each model parameter is mapped as the storage data of the short less than pre-set first threshold by corresponding mapping function.
As a kind of embodiment, corresponding 3rd model parameter of the parameter sets to be compressed and the 4th mould can be obtained
Shape parameter.It should be noted that model of the 3rd model parameter for parameter values maximum in the parameter sets to be compressed
Parameter, the 4th model parameter are the model parameter of parameter values minimum in the parameter sets to be compressed.Further according to described
3rd model parameter and the 4th model parameter determine the corresponding Compression Strategies.Optionally, according to the 3rd model parameter
And the 4th model parameter, determining the mode of the corresponding Compression Strategies can be:When the 3rd model parameter and the 4th mould
When difference between shape parameter is less than default second threshold, it is determined that the corresponding Compression Strategies are the first plan pre-seted
Slightly;When the difference between the 3rd model parameter and the 4th model parameter is more than default second threshold, it is determined that corresponding
The Compression Strategies be pre-set second strategy.Above-mentioned second threshold can be 255.Above-mentioned first strategy and the second strategy
Each correspond to a mapping function.The mapping parameters of above-mentioned mapping function can be according to the parameter sets to be compressed corresponding
Three model parameters and the 4th model parameter determine.
Different pressures is used for different parameter sets to be compressed by the cooperation of step S101 and step S102
Contracting strategy, had both ensured that model parameter was undistorted, and can also accomplish the compression of optimum efficiency.
Step S103, by each model parameter in the parameter sets to be compressed, according to the Compression Strategies into
Row compression is handled, and obtains the storage parameter of data type corresponding with the Compression Strategies.
In the embodiment of the present invention, the parameter values of each model parameter in the parameter sets to be compressed are first utilized into correspondence
The mapping functions of Compression Strategies handled, then will treated that parameter values are stored with the corresponding data type of Compression Strategies
In electronic equipment 100, to obtain storage parameter.Optionally, when the Compression Strategies are tactful for described first, successively by institute
It states each model parameter in parameter sets to be compressed and is mapped as the depositing without character type that numerical value is less than the second threshold
Store up data.When the Compression Strategies are tactful for described second, successively by each mould in the parameter sets to be compressed
Shape parameter is mapped as storage data of the numerical value less than the short of the first threshold.
Exemplified by using the first strategy and linear mapping function, first by corresponding 3rd model parameter of parameter sets to be compressed
Parameter values be mapped as 255, the parameter values of corresponding 4th model parameter are mapped as 0, recycle the Linear Mapping letter
Other model parameters in parameter sets to be compressed are mapped between 0-255 by number successively.As a kind of embodiment, it is assumed that linear
Mapping function is:
Y=kx+b,
X is taken into the 3rd model parameter respectively and y takes that 255 and x takes the 4th model parameter and y takes 0 to bring into state mapping relations
In, to obtain the value of k and b, above-mentioned k is corresponding mapping parameters with b,
K=255/ (f_max-f_min),
B=f_min*255/ (f_min-f_max),
Above-mentioned f_max is the parameter values of corresponding 3rd model parameter, and above-mentioned f_min is the ginseng of corresponding 4th model parameter
Number numerical value.The value of k and b is preserved with float floating types again.X is taken to the model in parameter sets to be compressed successively again
The parameter values of parameter are the parameter values after the corresponding mapping of model parameter to obtain the value of corresponding y.It will be to be compressed
Parameter values after the corresponding mapping of each model parameter of parameter sets carry out being stored in electronics in the form of no character type data
In equipment 100, to obtain corresponding storage parameter.
Using the separate same as described above of the second strategy, difference lies in correspond to corresponding 3rd model parameter for the two
Parameter values be mapped as first threshold, and the numerical value of other model parameters in parameter sets to be compressed is subjected to mapping processing and is
It after the parameter values of first threshold, is stored in electronic equipment 100 with short data, is joined with obtaining corresponding storage
Number.
The compression to model can be efficiently realized by above-mentioned steps and is stored in electronic equipment 100.Avoid mould
Influence of the type size to 100 performance of electronic equipment.When needing using the model, as shown in figure 4, the method further includes:
Step S201 is called when detecting a storage parameter in the pending model, obtains and be called
Store the corresponding Compression Strategies of parameter.
In embodiments of the present invention, can by judging the data type belonging to the storage parameter of the calling, then
The corresponding Compression Strategies of the storage parameter of the calling are determined according to the data type.
Step S202 obtains decompression strategy according to the Compression Strategies.
In embodiments of the present invention, can corresponding inverse function be obtained according to the corresponding mapping function of Compression Strategies, and with
The inverse function is as decompression strategy.Specifically, the mapping parameters that mapping function is obtained by inquiring about are obtained, and according to mapping parameters
Obtain inverse function.Example is connected, can inverse function be obtained according to the value of the k preserved, the value of b and corresponding mapping function.
The called storage parameter is carried out decompression processing, with acquisition pair by step S203 using the decompression strategy
The available model parameter answered.
In embodiments of the present invention, at can be using numerical value of the corresponding inverse function of decompression strategy to storing parameter
Reason, the numerical value of the model parameter after being decompressed with generation, and stored with real-coded GA, so as to the identifiable model parameter quilt of model
It calls.So that it is guaranteed that the machine learning function can be used normally.The numerical value of model parameter after decompression with before corresponding compression
Model parameter it is basically identical.In other embodiments, after calling, determine that the model parameter of the floating type does not use
It afterwards, can be with the model parameter of the corresponding deletion floating type.
Fig. 5 shown with a kind of corresponding model parameter processing unit 200 of the above method, the details side in following apparatus
Case is referred to the above method to realize, described device is applied in electronic equipment 100.Model parameter processing includes:
Acquisition module 201, for according to pending model, obtaining the corresponding parameter set to be compressed of the pending model
It closes, the parameter sets to be compressed include multiple model parameters.
Determining module 202, for according to the model parameter in the parameter sets to be compressed, determining Compression Strategies.
Compression module 203, for by each model parameter in the parameter sets to be compressed, according to the compression
Strategy is compressed processing, obtains the storage parameter of data type corresponding with the Compression Strategies.
The embodiment of the present invention further discloses a kind of storage medium, is stored thereon with computer program, the computer program
The model parameter processing method that present invention discloses is realized when being performed by processor 103.
To be situated between in conclusion an embodiment of the present invention provides a kind of model parameter processing method, device, electronic equipment and storages
Matter.The method is applied to the electronic equipment, the method may include according to pending model, obtains the pending mould
The corresponding parameter sets to be compressed of type, the parameter sets to be compressed include multiple model parameters;According to the parameter to be compressed
Model parameter in set, determines Compression Strategies;By each model parameter in the parameter sets to be compressed, according to institute
It states Compression Strategies and is compressed processing, obtain the storage parameter of data type corresponding with the Compression Strategies.So as to pass through root
Compression Strategies are neatly selected according to the concrete condition of model parameter, and the corresponding data type of conversion model parameters is to reduce model
Size, realization are simple and efficient.Meanwhile cause model parameter distortion by the way that applicable Compression Strategies is selected to avoid compression process.
In several embodiments provided herein, it should be understood that disclosed apparatus and method can also pass through
Other modes are realized.The apparatus embodiments described above are merely exemplary, for example, flow chart and block diagram in attached drawing
Show the devices of multiple embodiments according to the present invention, method and computer program product architectural framework in the cards,
Function and operation.In this regard, each box in flow chart or block diagram can represent the one of a module, program segment or code
Part, a part for the module, program segment or code include one or more and are used to implement holding for defined logic function
Row instruction.It should also be noted that at some as in the realization method replaced, the function that is marked in box can also be to be different from
The order marked in attached drawing occurs.For example, two continuous boxes can essentially perform substantially in parallel, they are sometimes
It can perform in the opposite order, this is depending on involved function.It is it is also noted that every in block diagram and/or flow chart
The combination of a box and the box in block diagram and/or flow chart can use function or the dedicated base of action as defined in performing
It realizes or can be realized with the combination of specialized hardware and computer instruction in the system of hardware.
In addition, each function module in each embodiment of the present invention can integrate to form an independent portion
Point or modules individualism, can also two or more modules be integrated to form an independent part.
If the function is realized in the form of software function module and is independent production marketing or in use, can be with
It is stored in a computer read/write memory medium.Based on such understanding, technical scheme is substantially in other words
The part contribute to the prior art or the part of the technical solution can be embodied in the form of software product, the meter
Calculation machine software product is stored in a storage medium, is used including some instructions so that a computer equipment (can be
People's computer, server or network equipment etc.) perform all or part of the steps of the method according to each embodiment of the present invention.
And foregoing storage medium includes:USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited
The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic disc or CD.
It should be noted that herein, relational terms such as first and second and the like are used merely to a reality
Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation
In any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to
Non-exclusive inclusion, so that process, method, article or equipment including a series of elements not only will including those
Element, but also including other elements that are not explicitly listed or further include as this process, method, article or equipment
Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that
Also there are other identical elements in process, method, article or equipment including the element.
The foregoing is only a preferred embodiment of the present invention, is not intended to limit the invention, for the skill of this field
For art personnel, the invention may be variously modified and varied.Within the spirit and principles of the invention, that is made any repaiies
Change, equivalent substitution, improvement etc., should all be included in the protection scope of the present invention.It should be noted that:Similar label and letter exists
Similar terms is represented in following attached drawing, therefore, once being defined in a certain Xiang Yi attached drawing, is then not required in subsequent attached drawing
It is further defined and is explained.
The above description is merely a specific embodiment, but protection scope of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can readily occur in change or replacement, should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention described should be subject to the protection scope in claims.