Calculation optimization method and device for Sigmoid class function and medium
Patent Information
- Application Number
- CN202511218162.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-12-02
Smart Images

Figure CN121052299A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, and medium for optimizing the calculation of Sigmoid-type functions. Background Technology
[0002] Nonlinear activation functions are a key component of various types of neural networks, enabling them to learn and represent complex data patterns. Commonly used nonlinear activation functions include sigmoid-like functions, which are frequently used in deep learning for probabilistic modeling, loss calculation, or stable numerical computation.
[0003] In the process of realizing this invention, the inventors discovered the following defects in the prior art: Currently, for Sigmoid-like functions, such as the Log Sigmoid function, the calculation is performed by concatenating the Log operator and the Sigmoid operator, which leads to low accuracy and large error in the calculation results. For other Sigmoid-like functions, the computational load is relatively large and the accuracy is relatively low. Summary of the Invention
[0004] This invention provides a method, apparatus, and medium for optimizing the calculation of Sigmoid functions, thereby reducing computational load and error and improving the calculation accuracy of Sigmoid functions.
[0005] According to one aspect of the present invention, a method for optimizing the computation of Sigmoid-type functions is provided, comprising:
[0006] Real-time reception of the current independent variable and target independent variable solution function corresponding to the Sigmoid class function;
[0007] The Sigmoid function computation optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask generator, and a second mask generator.
[0008] The absolute value calculation unit processes the current independent variable to calculate the standard current independent variable, and combines it with the target independent variable solution function. Then, Taylor expansion is performed through each of the linear fitters to obtain the current first function calculation result.
[0009] If the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then the second mask judgment generator is used to perform judgment processing on the current independent variable to generate the final function calculation result, and the final function calculation result is fed back to the user.
[0010] According to another aspect of the present invention, a computational optimization apparatus for Sigmoid-type functions is provided, comprising:
[0011] The module for receiving the current independent variable and target independent variable solution functions is used to receive the current independent variable and target independent variable solution functions corresponding to Sigmoid class functions in real time.
[0012] The Sigmoid function computation optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask generator, and a second mask generator.
[0013] The current first function calculation result determination module is used to process the current independent variable through the absolute value calculation unit, calculate the standard current independent variable, and combine it with the target independent variable solution function, and perform Taylor expansion processing operation through each of the linear fitters to obtain the current first function calculation result;
[0014] The final function calculation result generation and feedback module is used to, if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then combine the second mask judgment generator to perform judgment processing operations on the current independent variable, generate the final function calculation result, and feed the final function calculation result back to the user.
[0015] According to another aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the computation optimization method for Sigmoid class functions as described in any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the computation optimization method for Sigmoid class functions as described in any embodiment of the present invention.
[0017] The technical solution of this invention receives the current independent variable and the target independent variable solution function corresponding to the Sigmoid function in real time; processes the current independent variable through the absolute value calculation unit to calculate the standard current independent variable, and combines it with the target independent variable solution function, performing Taylor expansion processing through each of the linear fitters to obtain the current first function calculation result; if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then the second mask judgment generator performs judgment processing operation on the current independent variable to generate the final function calculation result, and feeds back the final function calculation result to the user. This solves the problems of large computational load, low accuracy, and large error in the calculation of Sigmoid functions in the prior art, reduces the complexity of Sigmoid function calculation, alleviates the memory pressure of Sigmoid function calculation, reduces computational load and error, and improves the accuracy and precision of Sigmoid function calculation results.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1a This is a flowchart of a calculation optimization method for Sigmoid-type functions provided in Embodiment 1 of the present invention;
[0021] Figure 1b This is a schematic diagram of the structure of a computation optimization system for Sigmoid functions according to Embodiment 1 of the present invention;
[0022] Figure 2 This is a detailed flowchart of a method for optimizing the calculation of Sigmoid functions according to Embodiment 2 of the present invention;
[0023] Figure 3 This is a schematic diagram of the structure of a computation optimization device for Sigmoid functions according to Embodiment 3 of the present invention;
[0024] Figure 4 This is a schematic diagram of the structure of an electronic device provided according to Embodiment 4 of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "target," "current," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] It is worth noting that the information collected in the technical solution of this application is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data all comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse; if the user chooses to refuse, the process will proceed to the expert decision-making process.
[0028] Example 1
[0029] Figure 1a The flowchart of a calculation optimization method for Sigmoid functions provided in Embodiment 1 of the present invention is applicable to the case of optimizing Sigmoid functions. The method can be executed by a Sigmoid function calculation optimization device, which can be implemented in hardware and / or software.
[0030] Correspondingly, such as Figure 1a As shown, the method includes:
[0031] S110. Receive the current independent variable and target independent variable solution function corresponding to the Sigmoid class function in real time.
[0032] The Sigmoid function computation optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask generator, and a second mask generator.
[0033] The Sigmoid class function includes at least one of the following: Sigmoid independent variable solution function, LogSigmoid independent variable solution function, and SiLU independent variable solution function.
[0034] In this embodiment, the Sigmoid, LogSigmoid, and SiLU independent variable solving functions have similar mathematical expressions, specifically as follows:
[0035] The expression for the Sigmoid function is equivalently transformed as follows: Further, the limit is obtained as Based on the Sigmoid independent variable solution function, the SiLU independent variable solution function can be further calculated as SiLU(x)=x·σ(x).
[0036] Accordingly, the expression for the LogSigmoid independent variable solution function is equivalently transformed as follows: Further, the limit is obtained as
[0037] It can be seen that the expressions for both the Sigmoid and LogSigmoid functions are symmetric; calculating the function value along either the positive or negative half-axis yields the full range of function values. In conventional Sigmoid calculations, results exceeding a threshold are treated as constants, leading to significant ULP (Unit in the Last Place) errors over a large negative interval. Using an exponential function to approximate input data exceeding the threshold ensures high-precision calculations across the entire range of 32-bit floating-point numbers.
[0038] Generally, complex functions can be approximated using polynomials. An nth-degree polynomial is the partial sum of the first n+1 terms of a Taylor series, and the approximation becomes increasingly accurate as n increases. Due to the symmetry of the expression, polynomial approximations can be performed on the positive half-axis region of a nonlinear function. For input variables exceeding a threshold, exponential functions can be used for approximation. Finally, the final function calculation is performed.
[0039] S120. The current independent variable is processed by the absolute value calculation unit to calculate the standard current independent variable, and combined with the target independent variable solution function, Taylor expansion is performed by each of the linear fitters to obtain the current first function calculation result.
[0040] Optionally, the step of combining the target independent variable solution function and performing Taylor expansion processing through each of the linear fitters to obtain the current first function calculation result includes: obtaining the target Taylor expansion order corresponding to the current independent variable, and matching a corresponding number of current linear fitters according to the target Taylor expansion order; wherein, the target Taylor expansion order is the same as the number of current linear fitters; in each of the current linear fitters, obtaining the target Taylor expansion processing method corresponding to the target independent variable solution function, and performing Taylor expansion processing operation according to the target Taylor expansion processing method, combined with the standard current independent variable and the target independent variable solution function, to obtain the current first function calculation result.
[0041] In this embodiment, different Taylor expansion processing methods for different types of independent variable solution functions are pre-trained in the current linear fitter, and Taylor expansion processing operations of different orders can be performed according to the target independent variable solution functions obtained in real time.
[0042] Specifically, assuming the target Taylor expansion order is second, two current linear fitters are needed for the Taylor expansion operation. Specifically, two successive current linear fitters form a quadratic fitter, and the quadratic polynomial ax is calculated. 2 The result of +bx+c approximates the output of the nonlinear function, where x is the input data of the current independent variable, and a, b, and c are lookup table values. Specifically, the lookup table for each nonlinear function is stored in an on-chip cache to improve processing speed.
[0043] Specifically, x is processed in the first current linear fitter to determine the output y1 = ax + b; next, y1 = ax + b is input to the second current linear fitter to determine the output y2 = xy1 + c, which is expanded to obtain y2 = xy1 + c = ax 2 +bx+c yields the quadratic fitting result of the input data x for the current independent variable. This successive linear fitting method reduces the number of multipliers required, lowering complexity and the frequency of multiplier usage.
[0044] Furthermore, a Taylor expansion operation can be performed on the standard current independent variable and the target independent variable solution function to obtain the current first function calculation result.
[0045] S130. If the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then the second mask judgment generator is used to perform judgment processing on the current independent variable to generate the final function calculation result, and the final function calculation result is fed back to the user.
[0046] The first mask generator can be used to determine whether the current independent variable exceeds a preset threshold range, and then perform different processing based on the determination result. Different preset threshold ranges can correspond to different types of target independent variable solution functions.
[0047] The second mask generator is a generator that can modify the function calculation result by different offsets based on the function calculated by the target independent variable.
[0048] In this embodiment, it is necessary to first use the first mask judgment generator to determine whether the current independent variable is within the threshold range corresponding to the target independent variable solution function. If the current independent variable does not exceed the threshold range, the second mask judgment generator is used to perform judgment processing operations on the current independent variable to generate the final function calculation result.
[0049] Optionally, the step of combining the second mask judgment generator to perform judgment processing on the current independent variable and generating the final function calculation result includes: if the target independent variable solution function is a Sigmoid independent variable solution function, then the second mask judgment generator determines whether the current independent variable is less than zero; if so, then based on the current first function calculation result, a first branch result of the current first function calculation is generated; if not, then 1 is subtracted from the current first function calculation result to generate a second branch result of the current first function calculation; based on the current first function calculation first branch result and the current first function calculation second branch result, a target function calculation result is generated; based on the target independent variable solution function and the target function calculation result, a final function calculation result is generated.
[0050] Optionally, the step of combining the second mask judgment generator to perform judgment processing on the current independent variable and generating the final function calculation result includes: if the target independent variable solution function is a LogSigmoid independent variable solution function, then the second mask judgment generator determines whether the current independent variable is greater than zero; if so, then based on the current first function calculation result, a first branch result of the current first function calculation is generated; if not, then the current first function calculation result is added to the current independent variable to generate a second branch result of the current first function calculation; based on the first branch result of the current first function calculation and the second branch result of the current first function calculation, a target function calculation result is generated; based on the target independent variable solution function and the target function calculation result, a final function calculation result is generated.
[0051] Specifically, for the Sigmoid function, the generator needs to determine whether the current independent variable is less than zero through the second mask. If it is less than zero, it means that there is no need to transform the result of the current first function, and it is directly determined as the result of the first branch of the current first function.
[0052] If not, it means that the result of the current first function calculation needs to be transformed. For the Sigmoid independent variable solution function, 1 needs to be subtracted from the result of the current first function calculation to generate the result of the second branch of the current first function calculation.
[0053] Correspondingly, the result of the first branch calculated by the current first function and the result of the second branch calculated by the current first function can be combined to generate the result of the target function calculation, and then the final result of the function calculation can be generated.
[0054] In this embodiment, for the LogSigmoid independent variable solution function, it is necessary to use the second mask generator to determine whether the current independent variable is greater than zero. If it is greater than zero, it means that there is no need to transform the current first function calculation result, and it is directly determined as the first branch result of the current first function calculation.
[0055] If the result is not greater than zero, the current independent variable needs to be added to the result of the first function to generate the result of the second branch of the first function.
[0056] Correspondingly, the result of the first branch calculated by the current first function and the result of the second branch calculated by the current first function can be combined to generate the result of the target function calculation, and then the final result of the function calculation can be generated.
[0057] Optionally, the Sigmoid function calculation optimization system further includes a SiLU coefficient switch setting gate unit; the step of generating the final function calculation result based on the target independent variable solution function and the target function calculation result includes: if the target independent variable solution function is a Sigmoid independent variable solution function or a LogSigmoid independent variable solution function, then the target function calculation result is determined as the final function calculation result; if the target independent variable solution function is a SiLU independent variable solution function, then the SiLU coefficient switch setting gate unit is used to multiply the target function calculation result corresponding to the Sigmoid independent variable solution function by the current independent variable to calculate the final function calculation result.
[0058] In this embodiment, the expression for the SiLU independent variable solution function is SiLU(x) = x·σ(x). That is, after calculating the objective function calculation result corresponding to the Sigmoid independent variable solution function, the SiLU coefficient switch setting gate unit is used to multiply it by the current independent variable to obtain the final function calculation result.
[0059] The advantage of this setup is that by combining the calculation result of the objective function corresponding to the Sigmoid independent variable solution function, and using the SiLU coefficient switch to set the gate unit to perform the multiplication operation with the current independent variable, the computational complexity of the SiLU independent variable solution function can be reduced, and the memory pressure of Sigmoid-type functions can also be alleviated.
[0060] In this embodiment, the exponential function calculation unit calculates the current independent variable and the target independent variable solution function to obtain the current second function calculation result. If the first mask judgment generator determines that the current independent variable is not within the preset threshold range corresponding to the target independent variable solution function, then, in conjunction with the current second function calculation result, the second mask judgment generator performs a judgment processing operation on the current independent variable to generate the final function calculation result, and the final function calculation result is fed back to the user.
[0061] Figure 1b A schematic diagram of the structure of a computational optimization system for Sigmoid functions is provided. The computational optimization system 100 for Sigmoid functions includes: an absolute value calculation unit 101, at least one linear fitter 102, a first mask judgment generator 103, a second mask judgment generator 104, a SiLU coefficient switching setting gate unit 105, and an exponential function calculation unit 106.
[0062] The technical solution of this invention receives the current independent variable and the target independent variable solution function corresponding to the Sigmoid function in real time; processes the current independent variable through the absolute value calculation unit to calculate the standard current independent variable, and combines it with the target independent variable solution function, performing Taylor expansion processing through each of the linear fitters to obtain the current first function calculation result; if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then the second mask judgment generator performs judgment processing operation on the current independent variable to generate the final function calculation result, and feeds back the final function calculation result to the user. This solves the problems of large computational load, low accuracy, and large error in the calculation of Sigmoid functions in the prior art, reduces the complexity of Sigmoid function calculation, alleviates the memory pressure of Sigmoid function calculation, reduces computational load and error, and improves the accuracy and precision of Sigmoid function calculation results.
[0063] Example 2
[0064] Figure 2 The following is a detailed flowchart of a method for optimizing the calculation of Sigmoid functions, provided in Embodiment 2 of the present invention.
[0065] S210. Receive the current independent variable and target independent variable solution function corresponding to the Sigmoid class function in real time.
[0066] The Sigmoid function computation optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask generator, and a second mask generator.
[0067] S220. The current independent variable is processed by the absolute value calculation unit to calculate the standard current independent variable, and combined with the target independent variable solution function, Taylor expansion is performed by each of the linear fitters to obtain the current first function calculation result.
[0068] S230. The current independent variable and the target independent variable are calculated by the exponential function calculation unit to obtain the current second function calculation result.
[0069] S240. The first mask generator determines whether the current independent variable is within a preset threshold range corresponding to the target independent variable solution function; if yes, then execute S250; if no, then execute S260.
[0070] S250. Based on the current first function calculation result, the second mask judgment generator performs judgment processing operation on the current independent variable to generate the final function calculation result, and feeds back the final function calculation result to the user.
[0071] S260. Based on the current second function calculation result, the second mask judgment generator performs judgment processing operation on the current independent variable to generate the final function calculation result, and feeds back the final function calculation result to the user.
[0072] In this embodiment, the exponential function calculation unit needs to calculate the solution functions for the current independent variable and the target independent variable, and further calculate the result of the current second function. If the first mask generator determines that the current independent variable is not within the preset threshold range corresponding to the solution function of the target independent variable, it means that the current independent variable exceeds the preset threshold range, and the final function calculation result needs to be calculated by combining the result of the current second function.
[0073] Furthermore, based on the current calculation result of the second function, the second mask generator can be used to perform judgment processing on the current independent variable to generate the final function calculation result. The operations of using the second mask generator to perform judgment processing on the current independent variable and determining the final function calculation result based on the current calculation result of the second function are the same as the processing method in Embodiment 1 above, which generates the final function calculation result based on the current calculation result of the first function, and will not be repeated here.
[0074] The technical solution of this invention involves receiving the current independent variable and the target independent variable solution function corresponding to a Sigmoid-type function in real time; processing the current independent variable through the absolute value calculation unit to calculate the standard current independent variable, and combining it with the target independent variable solution function, performing Taylor expansion processing through each of the linear fitters to obtain the current first function calculation result; if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then combining the second mask judgment generator to perform judgment processing on the current independent variable, generating the final function calculation result, and providing feedback to the user on the final function calculation result; if the first mask judgment generator determines that the current independent variable is not within the preset threshold range corresponding to the target independent variable solution function, then based on the current second function calculation result obtained by the exponential function calculation unit from the current independent variable and the target independent variable solution function, performing judgment processing on the current independent variable through the second mask judgment generator, generating the final function calculation result, and providing feedback to the user on the final function calculation result. If the current independent variable is not within the threshold range corresponding to the solution function of the target independent variable, it can be calculated through the exponential function calculation unit, which can further improve the accuracy and precision of the calculation results of Sigmoid-type functions; reduce the complexity of Sigmoid-type function calculation, alleviate the memory pressure of Sigmoid-type function calculation, and reduce the amount of calculation and error.
[0075] Example 3
[0076] Figure 3 This is a schematic diagram of a computational optimization device for Sigmoid functions provided in Embodiment 3 of the present invention. The computational optimization device for Sigmoid functions provided in this embodiment can be implemented by software and / or hardware, and can be configured in a terminal device or server to implement a computational optimization method for Sigmoid functions according to an embodiment of the present invention. Figure 3 As shown, the device includes: a current independent variable and target independent variable solution function receiving module 310, a current first function calculation result determination module 320, and a final function calculation result generation and feedback module 330.
[0077] Among them, the current independent variable and target independent variable solution function receiving module 310 is used to receive the current independent variable and target independent variable solution functions corresponding to the Sigmoid class function in real time;
[0078] The Sigmoid function computation optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask generator, and a second mask generator.
[0079] The current first function calculation result determination module 320 is used to process the current independent variable through the absolute value calculation unit, calculate the standard current independent variable, and combine it with the target independent variable solution function, and perform Taylor expansion processing operation through each of the linear fitters to obtain the current first function calculation result;
[0080] The final function calculation result generation and feedback module 330 is used to perform a judgment processing operation on the current independent variable in conjunction with the second mask judgment generator if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, generate the final function calculation result, and feed the final function calculation result back to the user.
[0081] The technical solution of this invention receives the current independent variable and the target independent variable solution function corresponding to the Sigmoid function in real time; processes the current independent variable through the absolute value calculation unit to calculate the standard current independent variable, and combines it with the target independent variable solution function, performing Taylor expansion processing through each of the linear fitters to obtain the current first function calculation result; if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then the second mask judgment generator performs judgment processing operation on the current independent variable to generate the final function calculation result, and feeds back the final function calculation result to the user. This solves the problems of large computational load, low accuracy, and large error in the calculation of Sigmoid functions in the prior art, reduces the complexity of Sigmoid function calculation, alleviates the memory pressure of Sigmoid function calculation, reduces computational load and error, and improves the accuracy and precision of Sigmoid function calculation results.
[0082] Based on the above embodiments, the Sigmoid class function includes at least one of the following: Sigmoid independent variable solving function, LogSigmoid independent variable solving function, and SiLU independent variable solving function.
[0083] Based on the above embodiments, the current first function calculation result determination module 320 can be specifically used to: obtain the target Taylor expansion order corresponding to the current independent variable, and match a corresponding number of current linear fitters according to the target Taylor expansion order; wherein, the target Taylor expansion order is the same as the number of current linear fitters; in each of the current linear fitters, obtain the target Taylor expansion processing operation method corresponding to the target independent variable solution function, and perform Taylor expansion processing operation according to the target Taylor expansion processing operation method, combined with the standard current independent variable and the target independent variable solution function, to obtain the current first function calculation result.
[0084] Based on the above embodiments, the final function calculation result generation and feedback module 330 may specifically include: if the target independent variable solution function is a Sigmoid independent variable solution function, then the second mask judgment generator determines whether the current independent variable is less than zero; if so, then the current first function calculation first branch result is generated based on the current first function calculation result; if not, then 1 is subtracted from the current first function calculation result to generate the current first function calculation second branch result; the target function calculation result is generated based on the current first function calculation first branch result and the current first function calculation second branch result; and the final function calculation result is generated based on the target independent variable solution function and the target function calculation result.
[0085] Based on the above embodiments, the final function calculation result generation and feedback module 330 may further include: if the target independent variable solution function is a LogSigmoid independent variable solution function, then the second mask judgment generator determines whether the current independent variable is greater than zero; if so, then the current first function calculation first branch result is generated based on the current first function calculation result; if not, then the current first function calculation result is added to the current independent variable to generate the current first function calculation second branch result; the target function calculation result is generated based on the current first function calculation first branch result and the current first function calculation second branch result; and the final function calculation result is generated based on the target independent variable solution function and the target function calculation result.
[0086] Based on the above embodiments, the Sigmoid function calculation optimization system further includes a SiLU coefficient switching setting gate unit.
[0087] Based on the above embodiments, the final function calculation result generation and feedback module 330 may further include: if the target independent variable solution function is a Sigmoid independent variable solution function or a Log Sigmoid independent variable solution function, then the target function calculation result is determined as the final function calculation result; if the target independent variable solution function is a SiLU independent variable solution function, then the target function calculation result corresponding to the Sigmoid independent variable solution function is multiplied by the current independent variable through the SiLU coefficient switch setting gate unit to calculate the final function calculation result.
[0088] Based on the above embodiments, the sigmoid function calculation optimization system further includes an exponential function calculation unit.
[0089] Based on the above embodiments, a current second function calculation result determination module is further included, which can be specifically used to: after obtaining the current function calculation result by performing Taylor expansion processing through each of the linear fitters in combination with the target independent variable solution function, calculate the current independent variable and the target independent variable solution function according to the exponential function calculation unit to obtain the current second function calculation result; if the first mask judgment generator determines that the current independent variable is not within the preset threshold range corresponding to the target independent variable solution function, then in combination with the current second function calculation result, the second mask judgment generator performs judgment processing operation on the current independent variable to generate the final function calculation result, and feeds back the final function calculation result to the user.
[0090] The Sigmoid function calculation optimization device provided in this embodiment of the invention can execute the Sigmoid function calculation optimization method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method execution.
[0091] Example 4
[0092] Figure 4 A schematic diagram of an electronic device 10, which can be used to implement Embodiment 4 of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0093] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0094] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0095] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as computational optimization methods for Sigmoid-like functions.
[0096] In some embodiments, the computational optimization method for Sigmoid class functions may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the computational optimization method for Sigmoid class functions described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the computational optimization method for Sigmoid class functions by any other suitable means (e.g., by means of firmware).
[0097] The method includes: receiving in real time the current independent variable and the target independent variable solution function corresponding to the Sigmoid function; wherein, the Sigmoid function calculation optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask judgment generator, and a second mask judgment generator; processing the current independent variable through the absolute value calculation unit to calculate the standard current independent variable, and combining it with the target independent variable solution function, performing Taylor expansion processing through each of the linear fitters to obtain the current first function calculation result; if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then combining the second mask judgment generator to perform judgment processing operation on the current independent variable, generating the final function calculation result, and feeding back the final function calculation result to the user.
[0098] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0099] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0100] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0101] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0102] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0103] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0104] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0105] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
[0106] Example 5
[0107] Embodiment 5 of the present invention also provides a computer-readable storage medium, wherein the computer-readable instructions, when executed by a computer processor, are used to perform a computational optimization method for a Sigmoid-type function. The method includes: receiving in real-time the current independent variable and the target independent variable solution function corresponding to the Sigmoid-type function; wherein the Sigmoid-type function computational optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask judgment generator, and a second mask judgment generator; processing the current independent variable through the absolute value calculation unit to calculate a standard current independent variable, and combining it with the target independent variable solution function, performing Taylor expansion processing through each of the linear fitters to obtain a current first function calculation result; if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then combining the second mask judgment generator to perform judgment processing on the current independent variable, generating a final function calculation result, and feeding back the final function calculation result to the user.
[0108] Of course, the computer-executable instructions provided in the embodiments of the present invention, which include a computer-readable storage medium, are not limited to the method operations described above, but can also perform related operations in the computational optimization of Sigmoid class functions provided in any embodiment of the present invention.
[0109] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0110] It is worth noting that in the above embodiments of Sigmoid function calculation optimization, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of the present invention.
[0111] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for optimizing the computation of Sigmoid-type functions, characterized in that, include: Real-time reception of the current independent variable and target independent variable solution function corresponding to the Sigmoid class function; The Sigmoid function computation optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask generator, and a second mask generator. The absolute value calculation unit processes the current independent variable to calculate the standard current independent variable, and combines it with the target independent variable solution function. Then, Taylor expansion is performed through each of the linear fitters to obtain the current first function calculation result. If the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then the second mask judgment generator is used to perform judgment processing on the current independent variable to generate the final function calculation result, and the final function calculation result is fed back to the user.
2. The method according to claim 1, characterized in that, The Sigmoid class functions include at least one of the following: Sigmoid independent variable solving function, LogSigmoid independent variable solving function, and SiLU independent variable solving function.
3. The method according to claim 2, characterized in that, The method of combining the target independent variable solution function and performing Taylor expansion processing through each of the linear fitters to obtain the current first function calculation result includes: Obtain the target Taylor expansion order corresponding to the current independent variable, and match the corresponding number of current linear fitters based on the target Taylor expansion order; Wherein, the target Taylor expansion order is the same as the number of current linear fitters; In each of the current linear fitters, the target Taylor expansion processing method corresponding to the target independent variable solution function is obtained, and the Taylor expansion processing operation is performed according to the target Taylor expansion processing method, combined with the standard current independent variable and the target independent variable solution function, to obtain the current first function calculation result.
4. The method according to claim 3, characterized in that, The step of combining the second mask judgment generator to perform judgment processing on the current independent variable and generating the final function calculation result includes: If the target independent variable solution function is a Sigmoid independent variable solution function, then the second mask generator determines whether the current independent variable is less than zero; If so, then based on the current first function calculation result, generate the current first function calculation first branch result; If not, then subtract the current first function calculation result from 1 to generate the current first function calculation second branch result; Based on the result of the first branch calculated by the current first function and the result of the second branch calculated by the current first function, the result of the objective function calculation is generated. Based on the solution function for the target independent variable and the calculation result of the target function, the final function calculation result is generated.
5. The method according to claim 4, characterized in that, The step of combining the second mask judgment generator to perform judgment processing on the current independent variable and generating the final function calculation result includes: If the target independent variable solution function is a LogSigmoid independent variable solution function, then the second mask generator determines whether the current independent variable is greater than zero; If so, then based on the current first function calculation result, generate the current first function calculation first branch result; If not, then add the current independent variable to the current first function calculation result to generate the current first function calculation second branch result; Based on the result of the first branch calculated by the current first function and the result of the second branch calculated by the current first function, the result of the objective function calculation is generated. Based on the solution function for the target independent variable and the calculation result of the target function, the final function calculation result is generated.
6. The method according to claim 4 or 5, characterized in that, The Sigmoid-type function calculation optimization system also includes a SiLU coefficient switching setting gate unit; The step of generating the final function calculation result based on the solution function of the target independent variable and the calculation result of the target function includes: If the objective function is a Sigmoid function or a Log Sigmoid function, then the result of the objective function calculation is determined as the final function calculation result. If the target independent variable solution function is a SiLU independent variable solution function, then the SiLU coefficient switch setting gate unit multiplies the target function calculation result corresponding to the Sigmoid independent variable solution function by the current independent variable to calculate the final function calculation result.
7. The method according to claim 6, characterized in that, The sigmoid function computation optimization system also includes an exponential function computation unit; After the function is solved by combining the target independent variable and performing Taylor expansion processing through each of the linear fitters to obtain the current function calculation result, the method further includes: The exponential function calculation unit calculates the current independent variable and the target independent variable solution function to obtain the current second function calculation result; If the first mask judgment generator determines that the current independent variable is not within the preset threshold range corresponding to the target independent variable solution function, then, in conjunction with the current second function calculation result, the second mask judgment generator performs judgment processing on the current independent variable to generate the final function calculation result, and provides feedback of the final function calculation result to the user.
8. A computational optimization device for Sigmoid-type functions, characterized in that, include: The module for receiving the current independent variable and target independent variable solution functions is used to receive the current independent variable and target independent variable solution functions corresponding to Sigmoid class functions in real time. The Sigmoid function computation optimization system includes: an absolute value calculation unit, at least one linear fitter, a first mask generator, and a second mask generator. The current first function calculation result determination module is used to process the current independent variable through the absolute value calculation unit, calculate the standard current independent variable, and combine it with the target independent variable solution function, and perform Taylor expansion processing operation through each of the linear fitters to obtain the current first function calculation result; The final function calculation result generation and feedback module is used to, if the first mask judgment generator determines that the current independent variable is within a preset threshold range corresponding to the target independent variable solution function, then combine the second mask judgment generator to perform judgment processing operations on the current independent variable, generate the final function calculation result, and feed the final function calculation result back to the user.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements a computation optimization method for Sigmoid class functions as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute a computation optimization method for a Sigmoid class function as described in any one of claims 1-7.