WO2021139237A1 - 损失函数的优化方法、装置、设备及存储介质 - Google Patents

损失函数的优化方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2021139237A1
WO2021139237A1 PCT/CN2020/118303 CN2020118303W WO2021139237A1 WO 2021139237 A1 WO2021139237 A1 WO 2021139237A1 CN 2020118303 W CN2020118303 W CN 2020118303W WO 2021139237 A1 WO2021139237 A1 WO 2021139237A1
Authority
WO
WIPO (PCT)
Prior art keywords
weight
machine learning
slow
optimizer
learning task
Prior art date
Application number
PCT/CN2020/118303
Other languages
English (en)
French (fr)
Inventor
郭跃超
谯轶轩
唐义君
王俊
高鹏
谢国彤
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021139237A1 publication Critical patent/WO2021139237A1/zh

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
    • G06N3/044Recurrent networks, e.g. Hopfield networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • 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

Definitions

  • This application relates to the field of base frame operation and maintenance, and in particular to a loss function optimization method, device, equipment and storage medium.
  • the inventor realizes that in the later stage of optimizing the loss function of SGD, the loss function is prone to fall into a local minimum, which causes the loss function to jitter abnormally when converging, thus failing to reach the optimal situation of convergence, which leads to accurate convergence of the loss function. Rate and efficiency are low.
  • This application provides a method for optimizing the loss function, which is used to improve the convergence accuracy and convergence efficiency of the loss function.
  • the first aspect of the present application provides a method for optimizing a loss function, including: obtaining a machine learning task to be optimized, where the machine learning task is used to indicate the loss function in a convergent machine learning model; The machine learning task is trained to obtain the first slow weight, and the first slow weight is used for the result obtained after the instructing machine learning task is iterated by the first optimizer; the second optimizer is used to perform the machine learning task Training to obtain a second slow weight, the second slow weight is used to instruct the machine learning task to use the second optimizer to perform the result obtained after iteration; according to a preset combination formula, the first slow weight and the first slow weight The two slow weights are merged to obtain the target update weight; the target update weight of each iteration stage is calculated until the convergence of the loss function is completed.
  • the second aspect of the present application provides a loss function optimization device, including a memory, a processor, and computer-readable instructions stored on the memory and running on the processor, and the processor executes the computer
  • the following steps are implemented when the readable instructions: obtain the machine learning task to be optimized, the machine learning task is used to indicate the loss function in the convergent machine learning model; the first optimizer is used to train the machine learning task to obtain the first Slow weight.
  • the first slow weight is used to instruct the machine learning task to use the first optimizer to perform the iterative results; use the second optimizer to train the machine learning task to obtain the second slow weight, so The second slow weight is used to indicate the result obtained after the machine learning task is iterated by the second optimizer; the first slow weight and the second slow weight are combined according to a preset combining formula to obtain a target update Weight: Calculate the target update weight for each iteration stage until the convergence of the loss function is completed.
  • the third aspect of the present application provides a computer-readable storage medium that stores computer instructions in the computer-readable storage medium, and when the computer instructions run on the computer, the computer executes the following steps: Obtain the machine to be optimized Learning task, the machine learning task is used to indicate the loss function in the convergent machine learning model; the machine learning task is trained by the first optimizer to obtain the first slow weight, and the first slow weight is used in the Instruct the machine learning task to use the first optimizer to perform iterative results; use the second optimizer to train the machine learning task to obtain a second slow weight, and the second slow weight is used to indicate the machine learning task The result obtained after the second optimizer is used for iteration; the first slow weight and the second slow weight are combined according to the preset combining formula to obtain the target update weight; the target update weight at each iteration stage is calculated until Convergence of the loss function is completed.
  • the fourth aspect of the present application provides a loss function optimization device, including: an acquisition module for acquiring a machine learning task to be optimized, and the machine learning task is used to indicate a loss function in a convergent machine learning model; first optimization A module, configured to train the machine learning task by using a first optimizer to obtain a first slow weight, and the first slow weight is used for the result obtained after the instructing machine learning task to use the first optimizer to perform iteration; The second optimization module is configured to use a second optimizer to train the machine learning task to obtain a second slow weight, and the second slow weight is used to instruct the machine learning task to use the second optimizer to perform the iteration. Result of; merging module, used to merge the first slow weight and the second slow weight according to a preset merging formula, to obtain the target update weight; iterative module, used to calculate the target update of each iteration stage Weight until the loss function converges.
  • the machine learning task to be optimized is obtained, and the machine learning task is used to indicate the loss function in the convergent machine learning model;
  • the first optimizer is used to train the machine learning task to obtain the first Slow weight.
  • the first slow weight is used to instruct the machine learning task to use the first optimizer to perform the iterative results; use the second optimizer to train the machine learning task to obtain the second slow weight, so
  • the second slow weight is used to indicate the result obtained after the machine learning task is iterated by the second optimizer;
  • the first slow weight and the second slow weight are combined according to a preset combining formula to obtain a target update Weight: Calculate the target update weight in each iteration stage until the convergence of the loss function is completed.
  • the first slow weight calculated by the first optimizer and the second slow weight calculated by the second optimizer are integrated and calculated to obtain the target update weight, and finally the iterative calculation is performed until the loss function converges, which reduces
  • the calculation time for calculating the weight and the abnormal jitter of the loss function during convergence improve the convergence accuracy and convergence efficiency of the loss function.
  • FIG. 1 is a schematic diagram of an embodiment of a method for optimizing a loss function in an embodiment of the application
  • FIG. 2 is a schematic diagram of another embodiment of a method for optimizing a loss function in an embodiment of the application
  • FIG. 3 is a schematic diagram of an embodiment of a loss function optimization device in an embodiment of the application.
  • FIG. 4 is a schematic diagram of another embodiment of a loss function optimization device in an embodiment of the application.
  • Fig. 5 is a schematic diagram of an embodiment of a loss function optimization device in an embodiment of the application.
  • the embodiments of the present application provide a method, device, device, and storage medium for optimizing a loss function, which are used to improve the convergence accuracy and convergence efficiency of the loss function.
  • An embodiment of the method for optimizing the loss function in the embodiment of the present application includes:
  • the execution subject of the present application may be a loss function optimization device, and may also be a terminal or a server, which is not specifically limited here.
  • the embodiment of the present application takes the server as the execution subject as an example for description.
  • the general machine learning model uses a convex function as the loss function.
  • the convex function guarantees its minimum value.
  • the most common method used in deep learning to find the minimum value of the convex function It is the gradient descent method, which is the main function of the optimizer in deep learning.
  • the machine learning task here refers to the loss function that needs to be optimized in deep learning.
  • the loss function plays a very important role in deep metric learning. Many loss functions for deep metric learning are built on sample pairs or sample triples.
  • the magnitude of the sample space is very large.
  • the gradient value of these sample-to-sample triples is almost 0.
  • the convergence speed of the learning algorithm will be very slow, and it will easily fall into the local optimum, resulting in loss The accuracy of the function decreases.
  • the first optimizer here uses stochastic gradient descent (SGD).
  • SGD stochastic gradient descent
  • the server selects hundreds of data points from millions of data samples at a time, and then calculates an SGD gradient based on these data points and updates the model parameters. Compared with the standard gradient descent method The time required to traverse all the samples and then update the parameters every time a sample is input is much shorter.
  • SGD can be used as the first optimizer to quickly train large data sets, improving the efficiency of optimizing the loss function, and The combination of the second optimizer achieves the effect of improving efficiency and accuracy.
  • the second optimizer here uses the adaptive moment estimation algorithm (adaptive moment estimation, Adam).
  • Adam is an adaptive learning rate optimization algorithm.
  • the adaptive learning rate optimization algorithm is optimized for the learning rate in the machine learning model.
  • Traditional optimization algorithms generally set the learning rate to a constant or adjust the learning rate according to the number of trainings. This setting ignores the possibility of other changes in the learning rate, resulting in a deviation in loss optimization.
  • the Adam optimizer can use one of the gradients.
  • the first-order moment estimation and the second-order moment estimation dynamically adjust the learning rate of each parameter to achieve the goal of accurately optimizing the loss function.
  • the main advantage of Adam is that after bias correction, the learning rate of each iteration is within a certain range, so that the adjusted parameters are more stable and the loss function is optimized more accurately.
  • the server uses the second optimizer to randomly select a sample i from the n training samples in the machine learning task, where n is an integer greater than 1 to update the loss of the sample i .
  • the first-order momentum term The correction value of m t is:
  • ⁇ 1 is the first-order momentum attenuation coefficient, generally taken as 0.9
  • the correction value of the second-order momentum term v t is:
  • ⁇ 2 is the second-order momentum attenuation coefficient, which is generally 0.999.
  • is the initial learning rate value, generally 0.01
  • is the numerical stability value, generally valued as 10 -8 to ensure that the denominator of the fraction is not zero, thus completing a loss optimization.
  • the first slow weight calculated by the server can be understood as the result of the loss function optimized by the first optimizer
  • the second slow weight calculated can be understood as the second optimizer optimized the same loss function.
  • the server combines the optimized first slow weight with the second slow weight, which is obtained by the preset combination formula
  • the target update weight is more in line with the true value.
  • the preset merge formula used by the server here is:
  • conforms to a certain probability distribution, without loss of generality
  • t is the current update time
  • T is the number of iterations of the overall training.
  • the server can get it through calculation versus In this way, the server can combine the first slow weight with the second slow weight to obtain the target update weight.
  • the server uses the results of k iteration steps to calculate the target update weights, connects the target update weights at different stages after the calculation, and obtains the result of loss optimization until the loss function converges.
  • Such an iterative update method effectively overcomes the jitter of the error function when the gradient is updated at the end of the training data, and ensures the convergence speed and accuracy of the convergence.
  • another embodiment of the method for optimizing the loss function in the embodiment of the present application includes:
  • the machine learning task here refers to the loss function that needs to be optimized in deep learning.
  • the loss function plays a very important role in deep metric learning.
  • Many loss functions for deep metric learning are built on sample pairs or sample three. Above tuples, the sample space has a large magnitude. In the later training of the learning model, the gradient value of these samples to the sample triples is almost 0. Without any targeted optimization, the convergence speed of the learning algorithm It will be very slow and easy to fall into the local optimum, resulting in a decrease in the accuracy of the loss function.
  • the gradient descent method is used to solve the machine learning task.
  • the gradient descent method is the most common algorithm for optimizing the loss function in the optimizer.
  • the stochastic gradient descent (SGD) method is used.
  • SGD stochastic gradient descent
  • the small batch of data makes the gradient drop randomly, and after continuous iteration and convergence, the optimal loss function is obtained.
  • Optimizers derived from SGD are divided into two categories: acceleration mechanism optimizer and adaptive learning rate mechanism optimizer. In this application, the above-mentioned SGD optimizer and adaptive learning rate mechanism optimizer are combined into Together, the optimal loss function is obtained.
  • machine learning task the server from the n training samples randomly selected sample i s, where, n is an integer greater than 1 for the sample subjected to losses update i s, the use of the server Calculate g t , where g t is the current gradient of SGD, J(W) is the cost function, ⁇ J(W) is the gradient, X(i s ) is the input sample, Y(i s ) is the output sample, and then the server uses The first preset formula and the calculated g t are used to calculate the first short-term fast weight.
  • the server After the server performs training iterations, the value of the first short-term weight updated at different points will be obtained.
  • the server After the server has calculated the first short-term weight of each moment, it needs to calculate the k consecutive first short-term weights.
  • the value of a short-term fast weight is integrated and calculated, the first slow weight is calculated using k first short-term fast weights, and multiple values are used for calculation, which can ensure the accuracy of the first slow weight and make the value of the first slow weight It is more in line with the overall value of the first short-term quick weight.
  • the value of k is 4, so that the calculated value is more suitable for data optimization, but the specific value of k can be modified according to actual conditions, and the value of k is not limited in this application.
  • the steps for the server to calculate the first slow weight are as follows: the server knows that the starting point of the first short-term fast weight is The successive first short-term quick weights are W 1 , W 2 , W 3 , W 4 , according to the second preset formula:
  • the server first uses the second optimizer to randomly select a sample i, i ⁇ 1,2,...,n ⁇ from n training samples of the machine learning task, where n is an integer greater than 1, and then the server uses the third
  • the preset formula calculates the updated second short-term quick weight W't +1 after i, and the third preset formula is:
  • t is the current time
  • W t ' is the weight parameter of the second optimizer at time t
  • is the initial learning rate
  • is the numerical stability value
  • t is the current moment
  • m t is the first-order momentum term
  • v t is the second-order momentum term
  • ⁇ 1 is the first-order momentum decay coefficient
  • ⁇ 2 is the second-order momentum decay coefficient
  • Is the corrected value of m t Is the modified value of v t
  • Gradient of weight W the server performs integrated calculation on the values of k second short-term fast weights to obtain the second slowest weight.
  • the second slowest weight is used to instruct the machine learning task to use the second optimizer to iterate the result.
  • the second optimizer here uses the adaptive moment estimation algorithm (adaptive moment estimation, Adam).
  • Adam is an adaptive learning rate optimization algorithm.
  • the adaptive learning rate optimization algorithm is optimized for the learning rate in the machine learning model.
  • the Adam optimizer can use the first-order moment estimation and the second-order moment estimation of the gradient to dynamically adjust the learning rate of each parameter to achieve the purpose of accurately optimizing the loss function.
  • the main advantage of Adam is that after bias correction, the learning rate of each iteration is within a certain range, so that the adjusted parameters are relatively stable, resulting in a more accurate optimization of the loss function.
  • a loss optimization is completed through Adam's iterative calculation.
  • the value of the second short-term weight updated at different points will be obtained. After the server has calculated the second short-term weight at each moment, it needs to calculate the second short-term weight of each time. 2. Calculate the value of the short-term fast weight, use the k second short-term fast weights to calculate the second slower weight, and use multiple values for calculation to ensure the accuracy of the second slowest weight, so that the second slowest weight The value is more in line with the overall second short-term weight value.
  • the value of k is 4, so that the calculated value is more suitable for data optimization, but the specific value of k can be modified according to actual conditions, and the value of k is not limited in this application.
  • the steps for the server to calculate the second slow weight are as follows: the server knows that the starting point of the second short-term weight is The second consecutive short-term weights are W 1 , W 2 , W 3 , W 4 , according to the second preset formula:
  • the second slowest weight is calculated as: In this way, the second slower weight that fits the second short-term fast weight more closely is obtained.
  • the server extracts the first slow weight and the second slow weight at time t, t ⁇ ⁇ 0,1,2,...,n ⁇ ; then the server takes the first slow weight and the second slow weight at time t Enter the preset merging formula to get the target update weight.
  • the preset merging formula is: among them, Update the weight for the target at time t, Is the first slow weight at time t, Is the second slowest weight at time t, ⁇ is the coefficient parameter, and the calculation formula of ⁇ is as follows:
  • t is the current update time
  • T is the number of iterations of overall training.
  • the first slow weight calculated by the server can be understood as the result of the loss function optimized by the first optimizer
  • the second slow weight calculated can be understood as the second optimizer optimized the same loss function.
  • the server combines the optimized first slow weight with the second slow weight, which is obtained by the preset combination formula
  • the target update weight is more in line with the true value.
  • the preset merge formula used by the server here is:
  • conforms to a certain probability distribution, without loss of generality
  • t is the current update time
  • T is the number of iterations of the overall training.
  • the server can obtain versus In this way, the server can merge the first slow weight with the second slow weight to obtain the target update weight.
  • the server will use the target update weights calculated in the first iteration stage as the starting point for calculating the short-term and fast weights in the second iteration stage, and use the above steps 202-204 to calculate the target update weights in the second iteration stage.
  • the step of calculating the target update weight of the second iteration stage by the server is the same as the step of calculating the target update weight of the first iteration stage, so this application will not repeat it here.
  • the server uses the results of k iteration steps to calculate the target update weights, connects the target update weights at different stages after the calculation, and obtains the result of loss optimization until the loss function converges.
  • Such an iterative update method effectively overcomes the jitter of the error function when the gradient is updated at the end of the training data, and ensures the convergence speed and accuracy of the convergence.
  • An embodiment of the device for optimizing the loss function in the embodiment of the application includes: obtaining The module 301 is used to obtain the machine learning task to be optimized, and the machine learning task is used to indicate the loss function in the convergent machine learning model; the first optimization module 302 is used to train the machine learning task using the first optimizer to obtain the first A slow weight, the first slow weight is used to indicate the result obtained after the machine learning task is iterated with the first optimizer; the second optimization module 303 is used to train the machine learning task using the second optimizer to obtain the second slow The second slow weight is used to indicate the result obtained after the machine learning task is iterated by the second optimizer; the merging module 304 is used to merge the first slow weight and the second slow weight according to a preset merging formula to obtain the target Update weights; the iteration module 305 is used to calculate the target update
  • another embodiment of the device for optimizing the loss function in the embodiment of the present application includes:
  • the obtaining module 301 is used to obtain the machine learning task to be optimized, and the machine learning task is used to indicate the loss function in the convergent machine learning model;
  • the first optimization module 302 is used to train the machine learning task by using the first optimizer to obtain The first slow weight, the first slow weight is used to indicate the result obtained after the machine learning task is iterated by the first optimizer;
  • the second optimization module 303 is used to train the machine learning task by the second optimizer to obtain the second Slow weight, the second slow weight is used to indicate the result obtained after the machine learning task is iterated by the second optimizer;
  • the merging module 304 is used to merge the first slow weight and the second slow weight according to a preset merging formula to obtain The target update weight;
  • the iterative module 305 is used to calculate the target update weight of each iteration stage until the convergence of the loss function is completed.
  • the first integration unit 3023 may also be specifically configured to: obtain k consecutive first short-term fast weight values, k ⁇ 2,3,...,n ⁇ ; according to the second preset formula and k consecutive The value of the first short-term fast weight calculates the first slow weight, and the second preset formula is:
  • t is the current moment
  • Is the first slow weight at time t Is the starting point for starting the first short-term fast weight
  • W t is the weight parameter at time t
  • W t+k is the weight parameter at time t+k
  • the first slow weight is used to instruct the machine learning task to use the first optimizer The result obtained after the iteration.
  • the second optimization module 303 includes: a second selection unit 3031, configured to use the second optimizer to randomly select a sample i, i ⁇ 1,2,...,n among n training samples of the machine learning task ⁇ , n is an integer greater than 1; the second calculation unit 3032 is used to calculate the updated second short-term fast weight W't +1 by using the third preset formula, and the third preset formula is:
  • t is the current time
  • W t ' is the weight parameter of the second optimizer at time t
  • is the initial learning rate
  • is the numerical stability value
  • t is the current moment
  • m t is the first-order momentum term
  • v t is the second-order momentum term
  • ⁇ 1 is the first-order momentum decay coefficient
  • ⁇ 2 is the second-order momentum decay coefficient
  • the gradient of the weight W; the second integration unit 3033 is used to integrate and calculate the values of the k second short-term fast weights to obtain the second slow weight, which is used to instruct the machine learning task to use the second optimizer
  • the result obtained after iteration is k ⁇ 2,3,...,n ⁇ .
  • the second integration unit 3033 may also be specifically configured to: obtain the values of k consecutive second short-term fast weight parameters, k ⁇ 2,3,...,n ⁇ ; according to the fourth preset formula and k Calculate the second slowest weight from the value of the second-fastest consecutive weight parameter.
  • the fourth preset formula is:
  • t is the current moment
  • Is the second slowest weight at time t Is the starting point for starting the second short-term fast weight
  • W t ' is the weight parameter at time t
  • W t+k ' is the weight parameter at time t+k
  • the second slow weight is used to instruct the machine learning task to adopt the first The result obtained by the optimizer after iterating.
  • the merging module 304 may also be specifically configured to: extract the first slow weight and the second slow weight at time t, t ⁇ 0,1,2,...,n ⁇ ; the first slow weight at time t
  • the weight and the second slowest weight are brought into the preset combination formula to obtain the target update weight.
  • the preset combination formula is: among them, Update the weight for the target at time t, Is the first slow weight at time t, Is the second slowest weight at time t, ⁇ is the coefficient parameter, and the calculation formula of ⁇ is as follows:
  • t is the current update time
  • T is the number of iterations of overall training.
  • the iteration module 305 may also be specifically configured to: obtain the target update weight in the first iteration stage, and use the target update weight in the first iteration stage as the starting point of the short-term and fast weight in the second iteration stage to calculate the second iteration.
  • the first slow weight calculated by the first optimizer and the second slow weight calculated by the second optimizer are integrated and calculated to obtain the target update weight, and finally the iterative calculation is performed until the loss function converges, which reduces
  • the calculation time for calculating the weight and the abnormal jitter of the loss function during convergence improve the convergence accuracy and convergence efficiency of the loss function.
  • FIG. 5 is a schematic structural diagram of a loss function optimization device provided by an embodiment of the present application.
  • the loss function optimization device 500 may have relatively large differences due to different configurations or performance, and may include one or more processors (central Processing units, CPU) 510 (for example, one or more processors) and memory 520, and one or more storage media 530 (for example, one or more storage devices with a large amount of data) storing application programs 533 or data 532.
  • the memory 520 and the storage medium 530 may be short-term storage or persistent storage.
  • the program stored in the storage medium 530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the device 500 for optimizing the loss function.
  • the processor 510 may be configured to communicate with the storage medium 530, and execute a series of instruction operations in the storage medium 530 on the device 500 for optimizing the loss function.
  • the loss function optimization device 500 may also include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input and output interfaces 560, and/or one or more operating systems 531, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc.
  • operating systems 531 such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc.
  • the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.
  • the computer-readable storage medium stores computer instructions. When the computer instructions are executed on the computer, the computer executes the following steps: obtain a machine learning task to be optimized, and the machine learning task is used to indicate the loss in the convergent machine learning model Function; Use the first optimizer to train the machine learning task to obtain the first slow weight, the first slow weight is used to instruct the machine learning task to use the first optimizer to iterate the results obtained; use the first The second optimizer trains the machine learning task to obtain a second slow weight, and the second slow weight is used to instruct the machine learning task to use the second optimizer to perform the iterative results; The first slow weight and the second slow weight are combined to obtain the target update weight; the target update weight of each iteration stage is calculated until the convergence of the loss function is completed.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of this application is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions.
  • a computer device which may be a personal computer, a server, or a network device, etc.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program code .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Biomedical Technology (AREA)
  • Molecular Biology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Medical Informatics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

本申请涉及基架运维领域,公开了一种损失函数的优化方法、装置、设备及存储介质,用于解决损失函数收敛准确率低下的问题。损失函数的优化方法包括:获取待优化的机器学习任务,机器学习任务用于指示收敛机器学习模型中的损失函数;利用第一优化器对机器学习任务进行训练,得到第一慢权重,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果;利用第二优化器对机器学习任务进行训练,得到第二慢权重,第二慢权重用于指示机器学习任务采用第二优化器进行迭代后得到的结果;依据预置合并公式将第一慢权重与第二慢权重进行合并,得到目标更新权重;计算每个迭代阶段的目标更新权重,直到损失函数收敛完成。

Description

损失函数的优化方法、装置、设备及存储介质
本申请要求于2020年5月14日提交中国专利局、申请号为202010405723.5、发明名称为“损失函数的优化方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及基架运维领域,尤其涉及一种损失函数的优化方法、装置、设备及存储介质。
背景技术
随着神经网络在计算机中的普及,深度学习是能够使神经网络学习如何抓取数据的特征,在抓取到数据特征后,抓取到的数据特征与真实的数据特征之间会有差异,因此需要及时优化损失函数。因此在深度学习网络中优化器是优化损失函数的重要工具。目前深度学习中的优化器常用的是随机梯度下降法(stochastic gradient descent,SGD),利用SGD优化损失函数时,会使用一个小批量的数据使得梯度随机下降,经过不断的迭代与收敛得到最优的损失函数。
发明人意识到SGD在进行优化损失函数的后期时,易出现损失函数陷入局部最小值的情况,导致损失函数在收敛时异常抖动从而达不到收敛的最优情况,进而导致损失函数的收敛准确率与效率低下。
发明内容
本申请提供一种损失函数的优化方法,用于提高损失函数的收敛准确率以及收敛效率。
本申请第一方面提供了一种损失函数的优化方法,包括:获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成。
本申请第二方面提供了一种损失函数的优化设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;依据预置合并公式将所述第一慢 权重与所述第二慢权重进行合并,得到目标更新权重;计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成。
本申请的第三方面提供了一种计算机可读存储介质,所述计算机可读存储介质中存储计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成。
本申请第四方面提供了一种损失函数的优化装置,包括:获取模块,用于获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;第一优化模块,用于利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;第二优化模块,用于利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;合并模块,用于依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;迭代模块,用于计算每个迭代阶段的所述目标更新权重,直到损失函数收敛完成。
本申请提供的技术方案中,获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;计算每个迭代阶段的所述目标更新权重,直到损失函数收敛完成。本申请实施例中,将第一优化器计算得到的第一慢权重与第二优化器计算得到的第二慢权重进行整合计算,得到目标更新权重,最后进行迭代计算直到损失函数收敛,减少了计算权重的计算时间以及损失函数在收敛时的异常抖动,提高了损失函数的收敛准确率以及收敛效率。
附图说明
图1为本申请实施例中损失函数的优化方法的一个实施例示意图;
图2为本申请实施例中损失函数的优化方法的另一个实施例示意图;
图3为本申请实施例中损失函数的优化装置的一个实施例示意图;
图4为本申请实施例中损失函数的优化装置的另一个实施例示意图;
图5为本申请实施例中损失函数的优化设备的一个实施例示意图。
具体实施方式
本申请实施例提供了一种损失函数的优化方法、装置、设备及存储介质,用于提高损失函数的收敛准确率以及收敛效率。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”或“具有”及其任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
为便于理解,下面对本申请实施例的具体流程进行描述,请参阅图1,本申请实施例中损失函数的优化方法的一个实施例包括:
101、获取待优化的机器学习任务,机器学习任务用于指示收敛机器学习模型中的损失函数;
可以理解的是,本申请的执行主体可以为损失函数的优化装置,还可以是终端或者服务器,具体此处不做限定。本申请实施例以服务器为执行主体为例进行说明。
需要说明的是,在深度学习的过程中,每一个机器学习模型都有一个损失函数,而深度学习的目的就是将损失函数最小化,然而,并非所有机器学习模型都能快速且精准的找到损失函数的最小值,甚至一些损失函数没有最小值,因此一般机器学习模型以凸函数作为损失函数,凸函数保证了其有最小值,在深度学习中用来寻找凸函数最小值的最常用的方法就是梯度下降法,这就是深度学习中优化器的主要作用。这里的机器学习任务指的是深度学习中需要优化的损失函数,损失函数在深度度量学习中起到了非常重要的作用,很多深度度量学习的损失函数构建在样本对或样本三元组之上,因而样本空间的量级非常大,一般而言,机器学习模型在训练过程中很难穷举学习所有的样本对或样本三元组,并且大多数样本对或者样本三元组的信息量很小,在后期学习模型的训练中,这些样本对样本三元组上梯度值几乎为0,若不做任何针对性的优化,学习算法的收敛速度会很慢,且易陷入局部最优,导致损失函数的准确率下降。
102、利用第一优化器对机器学习任务进行训练,得到第一慢权重,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果;
这里的第一优化器采用的是随机梯度下降法(stochastic gradient descent,SGD),对于梯度来说,SGD对梯度的要求很低,因此可以快速计算梯度,而对于引入的噪声来说,SGD能够对一定范围内的噪声进行收敛,例如:服务器每次从百万个数据样本中选取几百个数据点,然后根据这些数据点计算一个SGD梯度并更新模型参数,相比于标准梯度下降法的遍历全部样本,然后每输入一个样本更新一次参数的所需时间要缩短很多。
需要说明的是,SGD在对每个样本进行损失更新的时候,对于算法中的学习率的设定是非常关键的,若服务器设定的学习率较小,则会导致收敛速度缓慢,若服务器设定的学习率较大,则会导致损失函数在收敛时异常抖动从而达不到收敛的最优情况,因此需要大量的训练而得到合适的学习率;此外,SGD在进行优化损失函数的后期时,容易出现陷入局部最小值的情况,不能够有效的进行后期优化,由此在本申请中可以采用SGD作为第一优化器来迅速训练大型数据集,提高了优化损失函数的效率,并与第二优化器相结合,达到即提高效率有提高准确率的效果。
103、利用第二优化器对机器学习任务进行训练,得到第二慢权重,第二慢权重用于指示机器学习任务采用第二优化器进行迭代后得到的结果;
这里的第二优化器采用的是自适应时刻估计算法(adaptive moment estimation,Adam),Adam属于自适应学习率优化算法,自适应学习率优化算法是针对机器学习模型中的学习率进行优化的,传统的优化算法一般将学习率设置为常数或根据训练次数对学习率进行调节,这样的设置忽视了学习率其他变化的可能性,从而导致损失优化的偏差,通过Adam优化器可以利用梯度的一阶矩估计和二阶矩估计动态调整每个参数的学习率,达到准确优化损失函数的目的。Adam的优点主要在于经过偏置校正后,每一次迭代学习率在确定的范围内,使得调节的参数比较平稳,致使损失函数被更准确的优化。
Adam的迭代步骤如下:在机器学习任务中,服务器利用第二优化器在机器学习任务中n个训练样本中随机选取一个样本i,其中,n为大于1的整数针对样本i对其进行损失更新,服务器利用g t'=ΔJ(W t,i')计算g t',g t'为t次迭代后代价函数关于W'的梯度大小,其中,J(W')为代价函数,ΔJ(W t,i')为指定t时刻,指定分类i,代价函数关于W的梯度,然后服务器再分别计算一阶动量项m t与二阶动量项v t的修正值,其中,一阶动量项m t的修正值为:
Figure PCTCN2020118303-appb-000001
m t=β 1m t-1+(1-β 1)g t',
其中,β 1为一阶动量衰减系数,一般取值为0.9,二阶动量项v t的修正值为:
Figure PCTCN2020118303-appb-000002
其中,β 2为二阶动量衰减系数,一般取值为0.999,待服务器计算一阶动量项m t与二阶动量项v t的修正值后,服务器根据第三预置公式计算第二短时快权重,其中第三预置公式为:
Figure PCTCN2020118303-appb-000003
其中,η为初始的学习率取值,一般为0.01,ε为数值稳定量,一般取值为10 -8,以保证分式的分母不为零,这样就完成了一次损失的优化。
104、依据预置合并公式将第一慢权重与第二慢权重进行合并,得到目标更新权重;
需要说明的是,服务器计算得到的第一慢权重可以理解为第一优化器对损失函数进行 优化后的结果,计算得到的第二慢权重可以理解为第二优化器对相同损失函数进行优化后的结果,第一优化器与第二优化器对损失函数进行优化后的结果均存在误差,因此,服务器将优化过后的第一慢权重与第二慢权重相结合,这样通过预置合并公式得到目标更新权重更加符合真实值。在这里服务器利用到的预置合并公式为:
Figure PCTCN2020118303-appb-000004
其中,
Figure PCTCN2020118303-appb-000005
其中,α符合一定的概率分布,不失一般性,t为当前更新的时刻,T是整体训练的迭代次数,根据步骤102-103服务器可以通过计算得到
Figure PCTCN2020118303-appb-000006
Figure PCTCN2020118303-appb-000007
的值,这样服务器便可以将第一慢权重与第二慢权重合并,得到目标更新权重。
105、计算每个迭代阶段的目标更新权重,直到损失函数收敛完成。
可以理解的是,服务器利用k个迭代步骤的结果进行目标更新权重的计算,连接计算过后不同阶段目标更新权重,得到损失优化后的结果,直至损失函数收敛完成。这样的迭代更新方法,有效的克服了在训练数据结尾时,梯度更新时误差函数的抖动,保证了收敛速度和收敛的准确率。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。
请参阅图2,本申请实施例中损失函数的优化方法的另一个实施例包括:
201、获取待优化的机器学习任务,机器学习任务用于指示收敛机器学习模型中的损失函数;
需要说明的是,这里的机器学习任务指的是深度学习中需要优化的损失函数,损失函数在深度度量学习中起到了非常重要的作用,很多深度度量学习的损失函数构建在样本对或样本三元组之上,因而样本空间的量级很大,在后期学习模型的训练中,这些样本对样本三元组上梯度值几乎为0,若不做任何针对性的优化,学习算法的收敛速度会很慢且易陷入局部最优,导致损失函数的准确率下降。
本申请中利用到梯度下降法对机器学习任务进行求解,梯度下降法是优化器中优化损失函数最常见的算法,一般的,常用的是随机梯度下降法(stochastic gradient descent,SGD),使用一个小批量的数据使得梯度随机下降,经过不断的迭代与收敛得到最优的损失函数。由SGD的衍生变种优化器分为两大类:加速机制的优化器和自适应学习率机制优化器,在本申请中将上述SGD优化器与自适应学习率机制优化器两种优化器结合到一起,从而得到最优损失函数。
202、利用第一优化器对机器学习任务进行训练,得到第一慢权重,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果;
具体的,服务器利用第一优化器在机器学习任务的n个训练样本中随机选取一个样本i s,i s∈{1,2,…,n},n为大于1的整数;服务器利用第一预置公式W t+1=W ttg t计算i s更新 后的第一短时快权重W t+1,在第一预置公式中,t为当前时刻,W t为第一优化器t时刻的权重参数,η t为学习率,g t为梯度,其中,
Figure PCTCN2020118303-appb-000008
其中,J(W)为代价函数,ΔJ(W)为梯度,X(i s)为输入样本,Y(i s)为输出样本;服务器对k个第一短时快权重的值进行整合计算,得到第一慢权重,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果,k∈{2,3,…,n}。
举例来说:在机器学习任务中,服务器从n个训练样本中随机选取一个样本i s,其中,n为大于1的整数针对样本i s对其进行损失更新,服务器利用
Figure PCTCN2020118303-appb-000009
计算g t,这里的g t是SGD的当前梯度,J(W)为代价函数,ΔJ(W)为梯度,X(i s)为输入样本,Y(i s)为输出样本,之后服务器利用第一预置公式以及计算过后的g t来计算第一短时快权重,这里的第一预置公式为W t+1=W ttg t,t为当前时刻,W t为第一优化器t时刻的权重参数,η t为学习率,这样就完成了一次损失的优化。
进一步说明的是,待服务器进行训练迭代后,会得到不同点上更新的第一短时快权重的数值,在服务器计算完每个时刻的第一短时快权重后,需要对k个连续第一短时快权重的值进行整合计算,利用k个第一短时快权重计算第一慢权重,采用多个数值进行计算,可以确保第一慢权重的准确度,让第一慢权重的值更加贴合整体第一短时快权重的数值。
一般情况下,k的取值为4,这样计算起来的数值更贴合数据的优化,但具体k的取值可以根据实际情况进行修改,本申请中并不对k的值进行限定。
举例来说,当k=4时,服务器计算第一慢权重的步骤如下:服务器已知第一短时快权重的起点为
Figure PCTCN2020118303-appb-000010
依次连续的第一短时快权重为W 1、W 2、W 3、W 4,则根据第二预置公式:
Figure PCTCN2020118303-appb-000011
计算第一慢权重:
Figure PCTCN2020118303-appb-000012
这样就得到了更为贴合第一短时快权重的第一慢权重。
203、利用第二优化器对机器学习任务进行训练,得到第二慢权重,第二慢权重用于指示机器学习任务采用第二优化器进行迭代后得到的结果;
具体的,服务器首先利用第二优化器在机器学习任务的n个训练样本中随机选取一个样本i,i∈{1,2,…,n},n为大于1的整数;然后服务器利用第三预置公式计算i更新后的第二短时快权重W' t+1,第三预置公式为:
Figure PCTCN2020118303-appb-000013
其中,t为当前时刻,W t'为第二优化器t时刻的权重参数,η为初始学习率,ε为数值稳定量,
Figure PCTCN2020118303-appb-000014
为一阶动量项的修正值,
Figure PCTCN2020118303-appb-000015
的表达式如下:
Figure PCTCN2020118303-appb-000016
m t=β 1m t-1+(1-β 1)g t',
Figure PCTCN2020118303-appb-000017
其中,t为当前时刻,m t为一阶动量项,v t为二阶动量项,β 1为一阶动量衰减系数,β 2为二阶动量衰减系数,
Figure PCTCN2020118303-appb-000018
为m t的修正值,
Figure PCTCN2020118303-appb-000019
为v t的修正值,梯度g t'=ΔJ(W t,i'),其中,J(W')为代价函数,ΔJ(W t,i')为t时刻指定样本i的代价函数关于权重W的梯度;最后服务器对k个第二短时快权重的值进行整合计算,得到第二慢权重,第二慢权重用于指示机器学习任务采用第二优化器进行迭代后得到的结果,k∈{2,3,…,n}。
这里的第二优化器采用的是自适应时刻估计算法(adaptive moment estimation,Adam),Adam属于自适应学习率优化算法,自适应学习率优化算法是针对机器学习模型中的学习率进行优化的,通过Adam优化器可以利用梯度的一阶矩估计和二阶矩估计动态调整每个参数的学习率,达到准确优化损失函数的目的。Adam的优点主要在于经过偏置校正后,每一次迭代学习率在确定的范围内,使得调节的参数比较平稳,致使损失函数被更准确的优化,通过Adam的迭代计算完成了一次损失的优化。
需要说明的是,待服务器进行训练迭代后,会得到不同点上更新的第二短时快权重的数值,在服务器计算完每个时刻的第二短时快权重后,需要对k个连续第二短时快权重的值进行计算,利用k个第二短时快权重进行第二慢权重的计算,采用多个数值进行计算,可以确保第二慢权重的准确度,让第二慢权重的值更加贴合整体第二短时快权重的数值。
一般情况下,k的取值为4,这样计算起来的数值更贴合数据的优化,但具体k的取值可以根据实际情况进行修改,本申请中并不对k的值进行限定。
举例来说,当k=4时,服务器计算第二慢权重的步骤如下:服务器已知第二短时快权重的起点为
Figure PCTCN2020118303-appb-000020
依次连续的第二短时快权重为W 1、W 2、W 3、W 4,则根据第二预置公式:
Figure PCTCN2020118303-appb-000021
计算第二慢权重为:
Figure PCTCN2020118303-appb-000022
这样就得到了更为贴合第二短时快权重的第二慢权重。
204、依据预置合并公式将第一慢权重与第二慢权重进行合并,得到目标更新权重;
具体的,服务器提取t时刻下的第一慢权重与第二慢权重,t∈{0,1,2,…,n};然后服务器将t时刻下的第一慢权重与第二慢权重带入预置合并公式中,得到目标更新权重,预置合并公式为:
Figure PCTCN2020118303-appb-000023
其中,
Figure PCTCN2020118303-appb-000024
为t时刻的目标更新权重,
Figure PCTCN2020118303-appb-000025
为t时刻的第一慢权重,
Figure PCTCN2020118303-appb-000026
为t时刻的第二慢权重,α为系数参数,α的计算公式如下:
Figure PCTCN2020118303-appb-000027
其中,t为当前更新时刻,T是整体训练的迭代次数。
需要说明的是,服务器计算得到的第一慢权重可以理解为第一优化器对损失函数进行 优化后的结果,计算得到的第二慢权重可以理解为第二优化器对相同损失函数进行优化后的结果,第一优化器与第二优化器对损失函数进行优化后的结果均存在误差,因此,服务器将优化过后的第一慢权重与第二慢权重相结合,这样通过预置合并公式得到目标更新权重更加符合真实值。在这里服务器利用到的预置合并公式为:
Figure PCTCN2020118303-appb-000028
其中,
Figure PCTCN2020118303-appb-000029
其中,α符合一定的概率分布,不失一般性,t为当前更新的时刻,T是整体训练的迭代次数,根据步骤202与步骤203服务器可以通过计算得到
Figure PCTCN2020118303-appb-000030
Figure PCTCN2020118303-appb-000031
的值,这样服务器便可以将第一慢权重与第二慢权重进行合并,得到目标更新权重。
205、获取第一迭代阶段的目标更新权重,并将第一迭代阶段的目标更新权重作为第二迭代阶段短时快权重的起始点,计算第二迭代阶段的目标更新权重;
可以理解的是,服务器将在第一迭代阶段计算得到的目标更新权重,作为计算第二迭代阶段短时快权重的起点,利用上述步骤202-204的方法,计算第二迭代阶段的目标更新权重。服务器计算第二迭代阶段的目标更新权重的步骤与计算第一迭代阶段的目标更新权重的步骤相同,因此本申请不在此处赘述。
206、将第二迭代阶段的目标更新权重作为第三迭代阶段短时快权重的起始点,计算第三迭代阶段的目标更新权重,计算剩余迭代阶段的目标更新权重,直到损失函数收敛完成。
可以理解的是,服务器利用k个迭代步骤的结果进行目标更新权重的计算,连接计算过后不同阶段目标更新权重,得到损失优化后的结果,直至损失函数收敛完成。这样的迭代更新方法,有效的克服了在训练数据结尾时,梯度更新时误差函数的抖动,保证了收敛速度和收敛的准确率。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。
上面对本申请实施例中损失函数的优化方法进行了描述,下面对本申请实施例中损失函数的优化装置进行描述,请参阅图3,本申请实施例中损失函数的优化装置一个实施例包括:获取模块301,用于获取待优化的机器学习任务,机器学习任务用于指示收敛机器学习模型中的损失函数;第一优化模块302,用于利用第一优化器对机器学习任务进行训练,得到第一慢权重,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果;第二优化模块303,用于利用第二优化器对机器学习任务进行训练,得到第二慢权重,第二慢权重用于指示机器学习任务采用第二优化器进行迭代后得到的结果;合并模块304,用于依据预置合并公式将第一慢权重与第二慢权重进行合并,得到目标更新权重;迭代模块305,用于计算每个迭代阶段的目标更新权重,直到损失函数收敛完成。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。
请参阅图4,本申请实施例中损失函数的优化装置的另一个实施例包括:
获取模块301,用于获取待优化的机器学习任务,机器学习任务用于指示收敛机器学习模型中的损失函数;第一优化模块302,用于利用第一优化器对机器学习任务进行训练,得到第一慢权重,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果;第二优化模块303,用于利用第二优化器对机器学习任务进行训练,得到第二慢权重,第二慢权重用于指示机器学习任务采用第二优化器进行迭代后得到的结果;合并模块304,用于依据预置合并公式将第一慢权重与第二慢权重进行合并,得到目标更新权重;迭代模块305,用于计算每个迭代阶段的目标更新权重,直到损失函数收敛完成。
可选的,第一优化模块302包括:第一选取单元3021,用于利用第一优化器在机器学习任务的n个训练样本中随机选取一个样本i s,i s∈{1,2,…,n},n为大于1的整数;第一计算单元3022,用于利用第一预置公式W t+1=W ttg t计算i s更新后的第一短时快权重W t+1,在第一预置公式中,t为当前时刻,W t为第一优化器t时刻的权重参数,η t为学习率,g t为梯度,其中,
Figure PCTCN2020118303-appb-000032
其中,J(W)为代价函数,ΔJ(W)为梯度,X(i s)为输入样本,Y(i s)为输出样本;第一整合单元3023,用于对k个第一短时快权重的值进行整合计算,得到第一慢权重,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果,k∈{2,3,…,n}。
可选的,第一整合单元3023还可以具体用于:获取k个连续第一短时快权重的值,k∈{2,3,…,n};根据第二预置公式以及k个连续第一短时快权重的值计算第一慢权重,第二预置公式为:
Figure PCTCN2020118303-appb-000033
其中,t为当前时刻,
Figure PCTCN2020118303-appb-000034
为t时刻的第一慢权重,
Figure PCTCN2020118303-appb-000035
为起始第一短时快权重的起始点,W t为t时刻的权重参数,W t+k为t+k时刻的权重参数,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果。
可选的,第二优化模块303包括:第二选取单元3031,用于利用第二优化器在机器学习任务的n个训练样本中随机选取一个样本i,i∈{1,2,…,n},n为大于1的整数;第二计算单元3032,用于利用第三预置公式计算i更新后的第二短时快权重W' t+1,第三预置公式为:
Figure PCTCN2020118303-appb-000036
其中,t为当前时刻,W t'为第二优化器t时刻的权重参数,η为初始学习率,ε为数值稳定量,
Figure PCTCN2020118303-appb-000037
为一阶动量项的修正值,
Figure PCTCN2020118303-appb-000038
的表达式如下:
Figure PCTCN2020118303-appb-000039
m t=β 1m t-1+(1-β 1)g t',
Figure PCTCN2020118303-appb-000040
其中,t为当前时刻,m t为一阶动量项,v t为二阶动量项,β 1为一阶动量衰减系数,β 2为二阶动量衰减系数,
Figure PCTCN2020118303-appb-000041
为m t的修正值,
Figure PCTCN2020118303-appb-000042
为v t的修正值,梯度g t'=ΔJ(W t,i'),其中,J(W')为代价函数,ΔJ(W t,i')为t时刻指定样本i的代价函数关于权重W的梯度;第二整合单元3033,用于对k个第二短时快权重的值进行整合计算,得到第二慢权重,第二慢权重用于指示机器学习任务采用第二优化器进行迭代后得到的结果,k∈{2,3,…,n}。
可选的,第二整合单元3033还可以具体用于:获取k个连续第二短时快权重参数的值,k∈{2,3,…,n};根据第四预置公式以及k个连续第二快权重参数的值计算第二慢权重,第四预置公式为:
Figure PCTCN2020118303-appb-000043
其中,t为当前时刻,
Figure PCTCN2020118303-appb-000044
为t时刻的第二慢权重,
Figure PCTCN2020118303-appb-000045
为起始第二短时快权重的起始点,W t'为t时刻的权重参数,W t+k'为t+k时刻的权重参数,第二慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果。
可选的,合并模块304还可以具体用于:提取t时刻下的第一慢权重与第二慢权重,t∈{0,1,2,…,n};将t时刻下的第一慢权重与第二慢权重带入预置合并公式中,得到目标更新权重,预置合并公式为:
Figure PCTCN2020118303-appb-000046
其中,
Figure PCTCN2020118303-appb-000047
为t时刻的目标更新权重,
Figure PCTCN2020118303-appb-000048
为t时刻的第一慢权重,
Figure PCTCN2020118303-appb-000049
为t时刻的第二慢权重,α为系数参数,α的计算公式如下:
Figure PCTCN2020118303-appb-000050
其中,t为当前更新时刻,T是整体训练的迭代次数。
可选的,迭代模块305还可以具体用于:获取第一迭代阶段的目标更新权重,并将第一迭代阶段的目标更新权重作为第二迭代阶段短时快权重的起始点,计算第二迭代阶段的目标更新权重;将第二迭代阶段的目标更新权重作为第三迭代阶段短时快权重的起始点,计算第三迭代阶段的目标更新权重,计算剩余迭代阶段的目标更新权重,直到损失函数收敛完成。
本申请实施例中,将第一优化器计算得到的第一慢权重与第二优化器计算得到的第二慢权重进行整合计算,得到目标更新权重,最后进行迭代计算直到损失函数收敛,减少了计算权重的计算时间以及损失函数在收敛时的异常抖动,提高了损失函数的收敛准确率以及收敛效率。
上面图3和图4从模块化功能实体的角度对本申请实施例中的损失函数的优化装置进行详细描述,下面从硬件处理的角度对本申请实施例中损失函数的优化设备进行详细描述。
图5是本申请实施例提供的一种损失函数的优化设备的结构示意图,该损失函数的优化设备500可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器 (central processing units,CPU)510(例如,一个或一个以上处理器)和存储器520,一个或一个以上存储应用程序533或数据532的存储介质530(例如一个或一个以上海量存储设备)。其中,存储器520和存储介质530可以是短暂存储或持久存储。存储在存储介质530的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对损失函数的优化设备500中的一系列指令操作。更进一步地,处理器510可以设置为与存储介质530通信,在损失函数的优化设备500上执行存储介质530中的一系列指令操作。
损失函数的优化设备500还可以包括一个或一个以上电源540,一个或一个以上有线或无线网络接口550,一个或一个以上输入输出接口560,和/或,一个或一个以上操作系统531,例如Windows Serve,Mac OS X,Unix,Linux,FreeBSD等等。本领域技术人员可以理解,图5示出的损失函数的优化设备结构并不构成对损失函数的优化设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
本申请还提供一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,也可以为易失性计算机可读存储介质。计算机可读存储介质存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种损失函数的优化方法,其中,所述损失函数的优化方法包括:
    获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;
    利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;
    利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;
    依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;
    计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成。
  2. 根据权利要求1所述的损失函数的优化方法,其中,所述利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果包括:
    利用第一优化器在所述机器学习任务的n个训练样本中随机选取一个样本i s,i s∈{1,2,…,n},n为大于1的整数;
    利用第一预置公式W t+1=W ttg t计算i s更新后的第一短时快权重W t+1,在第一预置公式中,t为当前时刻,W t为第一优化器t时刻的权重参数,η t为学习率,g t为梯度,其中,
    Figure PCTCN2020118303-appb-100001
    其中,J(W)为代价函数,ΔJ(W)为梯度,X(i s)为输入样本,Y(i s)为输出样本;
    对k个所述第一短时快权重的值进行整合计算,得到第一慢权重,所述第一慢权重用于指示所述机器学习任务采用所述第一优化器进行迭代后得到的结果,k∈{2,3,…,n}。
  3. 根据权利要求2所述的损失函数的优化方法,其中,所述对k个所述第一短时快权重的值进行整合计算,得到第一慢权重,所述第一慢权重用于指示所述机器学习任务采用所述第一优化器进行迭代后得到的结果,k∈{2,3,…,n}包括:
    获取k个连续所述第一短时快权重的值,k∈{2,3,…,n};
    根据第二预置公式以及k个连续所述第一短时快权重的值计算第一慢权重,所述第二预置公式为:
    Figure PCTCN2020118303-appb-100002
    其中,t为当前时刻,
    Figure PCTCN2020118303-appb-100003
    为t时刻的第一慢权重,
    Figure PCTCN2020118303-appb-100004
    为起始第一短时快权重的起始点,W t为t时刻的权重参数,W t+k为t+k时刻的权重参数,第一慢权重用于指示机器学习任务 采用第一优化器进行迭代后得到的结果。
  4. 根据权利要求1所述的损失函数的优化方法,其中,所述利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果包括:
    利用第二优化器在所述机器学习任务的n个训练样本中随机选取一个样本i,i∈{1,2,…,n},n为大于1的整数;
    利用第三预置公式计算i更新后的第二短时快权重W' t+1,所述第三预置公式为:
    Figure PCTCN2020118303-appb-100005
    其中,t为当前时刻,W t'为第二优化器t时刻的权重参数,η为初始学习率,ε为数值稳定量,
    Figure PCTCN2020118303-appb-100006
    为一阶动量项的修正值,
    Figure PCTCN2020118303-appb-100007
    的表达式如下:
    Figure PCTCN2020118303-appb-100008
    m t=β 1m t-1+(1-β 1)g t',
    Figure PCTCN2020118303-appb-100009
    其中,t为当前时刻,m t为一阶动量项,v t为二阶动量项,β 1为一阶动量衰减系数,β 2为二阶动量衰减系数,
    Figure PCTCN2020118303-appb-100010
    为m t的修正值,
    Figure PCTCN2020118303-appb-100011
    为v t的修正值,梯度g t'=ΔJ(W t,i'),其中,J(W')为代价函数,ΔJ(W t,i')为t时刻指定样本i的代价函数关于权重W的梯度;
    对k个所述第二短时快权重的值进行整合计算,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用所述第二优化器进行迭代后得到的结果,k∈{2,3,…,n}。
  5. 根据权利要求4所述的损失函数的优化方法,其中,所述对k个所述第二短时快权重的值进行整合计算,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用所述第二优化器进行迭代后得到的结果,k∈{2,3,…,n}包括:
    获取k个连续所述第二短时快权重参数的值,k∈{2,3,…,n};
    根据第四预置公式以及k个连续所述第二快权重参数的值计算第二慢权重,所述第四预置公式为:
    Figure PCTCN2020118303-appb-100012
    其中,t为当前时刻,
    Figure PCTCN2020118303-appb-100013
    为t时刻的第二慢权重,
    Figure PCTCN2020118303-appb-100014
    为起始第二短时快权重的起始点,W t'为t时刻的权重参数,W t+k'为t+k时刻的权重参数,第二慢权重用于指示所述机器学习任务采用所述第一优化器进行迭代后得到的结果。
  6. 根据权利要求1所述的损失函数的优化方法,其中,所述依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重包括:
    提取t时刻下的所述第一慢权重与所述第二慢权重,t∈{0,1,2,…,n};
    将t时刻下的所述第一慢权重与所述第二慢权重带入预置合并公式中,得到目标更新权重,所述预置合并公式为:
    Figure PCTCN2020118303-appb-100015
    其中,
    Figure PCTCN2020118303-appb-100016
    为t时刻的目标更新权重,
    Figure PCTCN2020118303-appb-100017
    为t时刻的第一慢权重,
    Figure PCTCN2020118303-appb-100018
    为t时刻的第二慢权重,α为系数参数,α的计算公式如下:
    Figure PCTCN2020118303-appb-100019
    其中,t为当前更新时刻,T是整体训练的迭代次数。
  7. 根据权利要求1所述的损失函数的优化方法,其中,所述计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成包括:
    获取第一迭代阶段的目标更新权重,并将所述第一迭代阶段的目标更新权重作为第二迭代阶段短时快权重的起始点,计算第二迭代阶段的目标更新权重;
    将所述第二迭代阶段的目标更新权重作为第三迭代阶段短时快权重的起始点,计算第三迭代阶段的目标更新权重,计算剩余迭代阶段的目标更新权重,直到所述损失函数收敛完成。
  8. 一种损失函数的优化设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:
    获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;
    利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;
    利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;
    依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;
    计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成。
  9. 根据权利要求8所述的损失函数的优化设备,其中,所述处理器执行所述计算机可读指令实现所述利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果时,包括以下步骤:
    利用第一优化器在所述机器学习任务的n个训练样本中随机选取一个样本i s,i s∈{1,2,…,n},n为大于1的整数;
    利用第一预置公式W t+1=W ttg t计算i s更新后的第一短时快权重W t+1,在第一预置公式中,t为当前时刻,W t为第一优化器t时刻的权重参数,η t为学习率,g t为梯度,其中,
    Figure PCTCN2020118303-appb-100020
    其中,J(W)为代价函数,ΔJ(W)为梯度,X(i s)为输入样本,Y(i s)为输出样本;
    对k个所述第一短时快权重的值进行整合计算,得到第一慢权重,所述第一慢权重用于指示所述机器学习任务采用所述第一优化器进行迭代后得到的结果,k∈{2,3,…,n}。
  10. 根据权利要求9所述的损失函数的优化设备,其中,所述处理器执行所述计算机可读指令实现所述对k个所述第一短时快权重的值进行整合计算,得到第一慢权重,所述第一慢权重用于指示所述机器学习任务采用所述第一优化器进行迭代后得到的结果,k∈{2,3,…,n}时,包括以下步骤:
    获取k个连续所述第一短时快权重的值,k∈{2,3,…,n};
    根据第二预置公式以及k个连续所述第一短时快权重的值计算第一慢权重,所述第二预置公式为:
    Figure PCTCN2020118303-appb-100021
    其中,t为当前时刻,
    Figure PCTCN2020118303-appb-100022
    为t时刻的第一慢权重,
    Figure PCTCN2020118303-appb-100023
    为起始第一短时快权重的起始点,W t为t时刻的权重参数,W t+k为t+k时刻的权重参数,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果。
  11. 根据权利要求8所述的损失函数的优化设备,其中,所述处理器执行所述计算机可读指令实现所述利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果时,包括以下步骤:
    利用第二优化器在所述机器学习任务的n个训练样本中随机选取一个样本i,i∈{1,2,…,n},n为大于1的整数;
    利用第三预置公式计算i更新后的第二短时快权重W' t+1,所述第三预置公式为:
    Figure PCTCN2020118303-appb-100024
    其中,t为当前时刻,W t'为第二优化器t时刻的权重参数,η为初始学习率,ε为数值稳定 量,
    Figure PCTCN2020118303-appb-100025
    为一阶动量项的修正值,
    Figure PCTCN2020118303-appb-100026
    的表达式如下:
    Figure PCTCN2020118303-appb-100027
    m t=β 1m t-1+(1-β 1)g t',
    Figure PCTCN2020118303-appb-100028
    其中,t为当前时刻,m t为一阶动量项,v t为二阶动量项,β 1为一阶动量衰减系数,β 2为二阶动量衰减系数,
    Figure PCTCN2020118303-appb-100029
    为m t的修正值,
    Figure PCTCN2020118303-appb-100030
    为v t的修正值,梯度g t'=ΔJ(W t,i'),其中,J(W')为代价函数,ΔJ(W t,i')为t时刻指定样本i的代价函数关于权重W的梯度;
    对k个所述第二短时快权重的值进行整合计算,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用所述第二优化器进行迭代后得到的结果,k∈{2,3,…,n}。
  12. 根据权利要求11所述的损失函数的优化设备,其中,所述处理器执行所述计算机可读指令实现所述对k个所述第二短时快权重的值进行整合计算,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用所述第二优化器进行迭代后得到的结果,k∈{2,3,…,n}时,包括以下步骤:
    获取k个连续所述第二短时快权重参数的值,k∈{2,3,…,n};
    根据第四预置公式以及k个连续所述第二快权重参数的值计算第二慢权重,所述第四预置公式为:
    Figure PCTCN2020118303-appb-100031
    其中,t为当前时刻,
    Figure PCTCN2020118303-appb-100032
    为t时刻的第二慢权重,
    Figure PCTCN2020118303-appb-100033
    为起始第二短时快权重的起始点,W t'为t时刻的权重参数,W t+k'为t+k时刻的权重参数,第二慢权重用于指示所述机器学习任务采用所述第一优化器进行迭代后得到的结果。
  13. 根据权利要求8所述的损失函数的优化设备,其中,所述处理器执行所述计算机可读指令实现所述依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重时,还包括以下步骤:
    提取t时刻下的所述第一慢权重与所述第二慢权重,t∈{0,1,2,…,n};
    将t时刻下的所述第一慢权重与所述第二慢权重带入预置合并公式中,得到目标更新权重,所述预置合并公式为:
    Figure PCTCN2020118303-appb-100034
    其中,
    Figure PCTCN2020118303-appb-100035
    为t时刻的目标更新权重,
    Figure PCTCN2020118303-appb-100036
    为t时刻的第一慢权重,
    Figure PCTCN2020118303-appb-100037
    为t时刻的第二慢权重,α为系数参数,α的计算公式如下:
    Figure PCTCN2020118303-appb-100038
    其中,t为当前更新时刻,T是整体训练的迭代次数。
  14. 根据权利要求8所述的损失函数的优化设备,所述处理器执行所述计算机可读指令实现所述计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成时,包括以下步骤:
    获取第一迭代阶段的目标更新权重,并将所述第一迭代阶段的目标更新权重作为第二迭代阶段短时快权重的起始点,计算第二迭代阶段的目标更新权重;
    将所述第二迭代阶段的目标更新权重作为第三迭代阶段短时快权重的起始点,计算第三迭代阶段的目标更新权重,计算剩余迭代阶段的目标更新权重,直到所述损失函数收敛完成。
  15. 一种计算机可读存储介质,所述计算机可读存储介质中存储计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:
    获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;
    利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;
    利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;
    依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;
    计算每个迭代阶段的目标更新权重,直到所述损失函数收敛完成。
  16. 根据权利要求15所述的计算机可读存储介质,当所述计算机指令在计算机上运行时,使得计算机还执行以下步骤:
    利用第一优化器在所述机器学习任务的n个训练样本中随机选取一个样本i s,i s∈{1,2,…,n},n为大于1的整数;
    利用第一预置公式W t+1=W ttg t计算i s更新后的第一短时快权重W t+1,在第一预置公式中,t为当前时刻,W t为第一优化器t时刻的权重参数,η t为学习率,g t为梯度,其中,
    Figure PCTCN2020118303-appb-100039
    其中,J(W)为代价函数,ΔJ(W)为梯度,X(i s)为输入样本,Y(i s)为输出样本;
    对k个所述第一短时快权重的值进行整合计算,得到第一慢权重,所述第一慢权重用于指示所述机器学习任务采用所述第一优化器进行迭代后得到的结果,k∈{2,3,…,n}。
  17. 根据权利要求16所述的计算机可读存储介质,当所述计算机指令在计算机上运行 时,使得计算机还执行以下步骤:
    获取k个连续所述第一短时快权重的值,k∈{2,3,…,n};
    根据第二预置公式以及k个连续所述第一短时快权重的值计算第一慢权重,所述第二预置公式为:
    Figure PCTCN2020118303-appb-100040
    其中,t为当前时刻,
    Figure PCTCN2020118303-appb-100041
    为t时刻的第一慢权重,
    Figure PCTCN2020118303-appb-100042
    为起始第一短时快权重的起始点,W t为t时刻的权重参数,W t+k为t+k时刻的权重参数,第一慢权重用于指示机器学习任务采用第一优化器进行迭代后得到的结果。
  18. 根据权利要求15所述的计算机可读存储介质,当所述计算机指令在计算机上运行时,使得计算机还执行以下步骤:
    利用第二优化器在所述机器学习任务的n个训练样本中随机选取一个样本i,i∈{1,2,…,n},n为大于1的整数;
    利用第三预置公式计算i更新后的第二短时快权重W' t+1,所述第三预置公式为:
    Figure PCTCN2020118303-appb-100043
    其中,t为当前时刻,W t'为第二优化器t时刻的权重参数,η为初始学习率,ε为数值稳定量,
    Figure PCTCN2020118303-appb-100044
    为一阶动量项的修正值,
    Figure PCTCN2020118303-appb-100045
    的表达式如下:
    Figure PCTCN2020118303-appb-100046
    m t=β 1m t-1+(1-β 1)g t',
    Figure PCTCN2020118303-appb-100047
    其中,t为当前时刻,m t为一阶动量项,v t为二阶动量项,β 1为一阶动量衰减系数,β 2为二阶动量衰减系数,
    Figure PCTCN2020118303-appb-100048
    为m t的修正值,
    Figure PCTCN2020118303-appb-100049
    为v t的修正值,梯度g t'=ΔJ(W t,i'),其中,J(W')为代价函数,ΔJ(W t,i')为t时刻指定样本i的代价函数关于权重W的梯度;
    对k个所述第二短时快权重的值进行整合计算,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用所述第二优化器进行迭代后得到的结果,k∈{2,3,…,n}。
  19. 根据权利要求18所述的计算机可读存储介质,当所述计算机指令在计算机上运行时,使得计算机还执行以下步骤:
    获取k个连续所述第二短时快权重参数的值,k∈{2,3,…,n};
    根据第四预置公式以及k个连续所述第二快权重参数的值计算第二慢权重,所述第四预置公式为:
    Figure PCTCN2020118303-appb-100050
    其中,t为当前时刻,
    Figure PCTCN2020118303-appb-100051
    为t时刻的第二慢权重,
    Figure PCTCN2020118303-appb-100052
    为起始第二短时快权重的起始点,W t'为t时刻的权重参数,W t+k'为t+k时刻的权重参数,第二慢权重用于指示所述机器学习任务采用所述第一优化器进行迭代后得到的结果。
  20. 一种损失函数的优化装置,其中,所述损失函数的优化装置包括:
    获取模块,用于获取待优化的机器学习任务,所述机器学习任务用于指示收敛机器学习模型中的损失函数;
    第一优化模块,用于利用第一优化器对所述机器学习任务进行训练,得到第一慢权重,所述第一慢权重用于所述指示机器学习任务采用第一优化器进行迭代后得到的结果;
    第二优化模块,用于利用第二优化器对所述机器学习任务进行训练,得到第二慢权重,所述第二慢权重用于指示所述机器学习任务采用第二优化器进行迭代后得到的结果;
    合并模块,用于依据预置合并公式将所述第一慢权重与所述第二慢权重进行合并,得到目标更新权重;
    迭代模块,用于计算每个迭代阶段的所述目标更新权重,直到损失函数收敛完成。
PCT/CN2020/118303 2020-05-14 2020-09-28 损失函数的优化方法、装置、设备及存储介质 WO2021139237A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010405723.5 2020-05-14
CN202010405723.5A CN111738408A (zh) 2020-05-14 2020-05-14 损失函数的优化方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2021139237A1 true WO2021139237A1 (zh) 2021-07-15

Family

ID=72647265

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/118303 WO2021139237A1 (zh) 2020-05-14 2020-09-28 损失函数的优化方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN111738408A (zh)
WO (1) WO2021139237A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114254763A (zh) * 2021-12-27 2022-03-29 西安交通大学 机器学习模型修复方法、系统、计算机设备及存储介质
CN114463576A (zh) * 2021-12-24 2022-05-10 中国科学技术大学 一种基于重加权策略的网络训练方法
CN114692562A (zh) * 2022-03-16 2022-07-01 北京理工大学 一种高精度混合动态优先级多目标优化方法
CN116630398A (zh) * 2023-07-21 2023-08-22 浙江大学海南研究院 一种基于数据集凹凸性特征的优化器动量系数调控方法

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112183750A (zh) * 2020-11-05 2021-01-05 平安科技(深圳)有限公司 神经网络模型训练方法、装置、计算机设备及存储介质
CN112287089B (zh) * 2020-11-23 2022-09-20 腾讯科技(深圳)有限公司 用于自动问答系统的分类模型训练、自动问答方法及装置
CN113763501B (zh) * 2021-09-08 2024-02-27 上海壁仞智能科技有限公司 图像重建模型的迭代方法和图像重建方法
CN114647387A (zh) * 2022-05-23 2022-06-21 南京道成网络科技有限公司 一种适用于云端存储的缓存优化方法
CN116237935B (zh) * 2023-02-03 2023-09-15 兰州大学 一种机械臂协同抓取方法、系统、机械臂及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107909142A (zh) * 2017-11-14 2018-04-13 深圳先进技术研究院 一种神经网络的参数优化方法、系统及电子设备
CN108960318A (zh) * 2018-06-28 2018-12-07 武汉市哈哈便利科技有限公司 一种用于无人售货柜的采用双目视觉技术的商品识别算法
KR20190118387A (ko) * 2018-04-10 2019-10-18 배재대학교 산학협력단 합성곱 신경망 기반 이미지 처리 시스템 및 방법
CN111028306A (zh) * 2019-11-06 2020-04-17 杭州电子科技大学 基于AR2 U-Net神经网络的快速磁共振成像方法
CN111079896A (zh) * 2019-11-15 2020-04-28 苏州浪潮智能科技有限公司 一种超参数自适应调整方法与装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107909142A (zh) * 2017-11-14 2018-04-13 深圳先进技术研究院 一种神经网络的参数优化方法、系统及电子设备
KR20190118387A (ko) * 2018-04-10 2019-10-18 배재대학교 산학협력단 합성곱 신경망 기반 이미지 처리 시스템 및 방법
CN108960318A (zh) * 2018-06-28 2018-12-07 武汉市哈哈便利科技有限公司 一种用于无人售货柜的采用双目视觉技术的商品识别算法
CN111028306A (zh) * 2019-11-06 2020-04-17 杭州电子科技大学 基于AR2 U-Net神经网络的快速磁共振成像方法
CN111079896A (zh) * 2019-11-15 2020-04-28 苏州浪潮智能科技有限公司 一种超参数自适应调整方法与装置

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114463576A (zh) * 2021-12-24 2022-05-10 中国科学技术大学 一种基于重加权策略的网络训练方法
CN114463576B (zh) * 2021-12-24 2024-04-09 中国科学技术大学 一种基于重加权策略的网络训练方法
CN114254763A (zh) * 2021-12-27 2022-03-29 西安交通大学 机器学习模型修复方法、系统、计算机设备及存储介质
CN114254763B (zh) * 2021-12-27 2024-04-05 西安交通大学 机器学习模型修复方法、系统、计算机设备及存储介质
CN114692562A (zh) * 2022-03-16 2022-07-01 北京理工大学 一种高精度混合动态优先级多目标优化方法
CN114692562B (zh) * 2022-03-16 2024-05-24 北京理工大学 一种高精度混合动态优先级多目标优化方法
CN116630398A (zh) * 2023-07-21 2023-08-22 浙江大学海南研究院 一种基于数据集凹凸性特征的优化器动量系数调控方法
CN116630398B (zh) * 2023-07-21 2024-05-10 浙江大学海南研究院 一种基于数据集凹凸性特征的优化器动量系数调控方法

Also Published As

Publication number Publication date
CN111738408A (zh) 2020-10-02

Similar Documents

Publication Publication Date Title
WO2021139237A1 (zh) 损失函数的优化方法、装置、设备及存储介质
TWI794157B (zh) 自動多閾值特徵過濾方法及裝置
JP6685541B2 (ja) ユーザ信用スコアを最適化するための方法および装置
Yi et al. Stochastic search using the natural gradient
US20230078315A1 (en) Column ordering for input/output optimization in tabular data
US20190362222A1 (en) Generating new machine learning models based on combinations of historical feature-extraction rules and historical machine-learning models
US20170330054A1 (en) Method And Apparatus Of Establishing Image Search Relevance Prediction Model, And Image Search Method And Apparatus
US20230385652A1 (en) System and Method of Federated Learning with Diversified Feedback
WO2019223443A1 (zh) 数据库配置参数处理方法、装置、计算机设备和存储介质
CN110796258A (zh) 用于基于元学习来选择机器学习的模型的方法和设备
CN111512283B (zh) 数据库中的基数估算
CN109947940B (zh) 文本分类方法、装置、终端及存储介质
CN110458287B (zh) 神经网络优化器的参数更新方法、装置、终端及存储介质
WO2022095432A1 (zh) 神经网络模型训练方法、装置、计算机设备及存储介质
CN108509422B (zh) 一种词向量的增量学习方法、装置和电子设备
CN110661727A (zh) 数据传输优化方法、装置、计算机设备和存储介质
Cohen et al. Don't let the negatives bring you down: sampling from streams of signed updates
CN114936323B (zh) 图表示模型的训练方法、装置及电子设备
JP6819420B2 (ja) 学習プログラム、学習方法および学習装置
JP2021149988A (ja) 情報処理装置及び情報処理方法
WO2021000400A1 (zh) 导诊相似问题对生成方法、系统及计算机设备
JP2016031739A (ja) 生産制御支援装置および生産制御支援方法
JP6203313B2 (ja) 特徴選択装置、特徴選択方法およびプログラム
CN114677547B (zh) 一种基于自保持表征扩展的类增量学习的图像分类方法
Tavanaei et al. Unsupervised learning to rank aggregation using parameterized function optimization

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20911843

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20911843

Country of ref document: EP

Kind code of ref document: A1