1
Approximation of Hyperbolic Tangent Activation Function Using Hybrid Methods Maicon A. Sartin - Universidade do Estado de Mato Grosso (UNEMAT), Brazil. Alexandre C. R. da Silva - Universidade Estadual Paulista (UNESP), Brazil. The contribution of this work is the ap- proximation of a nonlinear function used in ANN, the popular hyperbolic tangent (HT) activation function (AF). The system architecture is composed of several sce- narios that provide a tradeoff of perfor- mance, precision and area used in FPGA. The results are compared in different sce- narios and with current literature on error analysis, area and system performance. Abstract The HT and sigmoid functions both pro- duce a curve with an “S” shape. HT con- tains values (±) and the output is be- tween [-1,1]. The behavior of the AF is nonlinear and has a steeper curve before saturation of the two ends. Four features can be observed on the HT: (i) there is symmetry between the y axis; (ii) For very large values of x, T( ) →±1; (iii) the central part is near a linear equation and the variation is greater; (iv) The output (Th (x)) is equal to its input values for x near zero. ( )= 1 - 1+ Table 1 - Analyzed Scenarios. N. Scenarios 1 HPR of 180 Elements 2 HPR of 212 Elements 3 HPR of 314 Elements 4 HPR of 340 Elements 5 HPR of 404 Elements 6 HPC of 180 Elements 7 HPC of 212 Elements 8 HPC of 340 Elements 9 HPC of 404 Elements Basic Concepts Table 2 - Errors Absolute and Relative Found Approximations Error_Max Error_Ave Rel_Ave Sc. 1 (180) 418 × 10 -3 105 × 10 -3 124 × 10 -3 Sc. 2 (212) 418 × 10 -3 103 × 10 -3 120 × 10 -3 Sc. 3 (314) 330 × 10 -3 680 × 10 -4 843 × 10 -4 Sc. 4 (340) 330 × 10 -3 718 × 10 -4 899 × 10 -4 Sc. 5 (404) 323 × 10 -3 680 × 10 -4 869 × 10 -4 Sc. 6 (180) 594 × 10 -3 275 × 10 -3 304 × 10 -3 Sc. 7 (212) 594 × 10 -3 275 × 10 -3 304 × 10 -3 Sc. 8 (340) 594 × 10 -3 236 × 10 -3 272 × 10 -3 Sc. 9 (404) 594 × 10 -3 228 × 10 -3 267 × 10 -3 Comb(Tommiska,03) 390 × 10 -3 170 × 10 -3 - Hybrid(Meher,10) 200 × 10 -2 172 × 10 -2 - Hybrid(Bajger;Omondi,08) 461 × 10 -4 135 × 10 -4 138 × 10 -3 Analysis of the Results This paper presented the implementation of a system for approximating a HT AF into a reconfigurable device. Scenarios 1 to 5 are good options in the precision HT AF to the FPGA. The scenarios 6 to 9 don’t need BRAM and the precision is relatively compromised with the previous scenarios, but has the best tradeoff. Conclusion The authors would like to thank the support of UNEMAT, UNESP and PPGEE, LPSSD, CAPES and CNPQ - process (309023/2012-2). Acknowledgements HPR (Hybrid with PWL and RALUT) and HPC (Hybrid with PWL and Combinational) methods use division into parts (PWL) with the goal of acquire high precision and an amount of elements adapted to the variation of interval. Combinational techniques and RALUT can reduce hardware resources with suitable. In the HPR hardware, the mapping is made from amount of addressing bits related with the scenario interval. To make mapping in the HPC hardware each interval contains a sum of products (SOP) to each output bit. SOP is made based in the amount of elements in interval and simplified with the Quine-McCluskey algorithm. Figure 1 - Hardware for Mapping the Outputs of the AF (HPR and HPC) Proposed Methods for the Approximation of the HT The system contains 500 inputs samples for the error analysis, area, and performance in implementing the HT AF in hardware. With all samples the implementation of the scenarios were run in approximately 40 μs for Spartan 3E platform, with clock period of 20 ns. Figure 2 - Approximation of the HT AF with 500 and 6 points for all scenarios The scenarios (1 to 5) (HPR) present the best accuracy, when compared with combinational methods (Scenarios 6 to 9) (HPC). But the HPR scenarios need of dedicated memory (BRAM), different of HPC scenar- ios that have just Boolean expressions. Analyzing the tradeoff between area and accuracy the scenario 9 is the best choose between all. In the results of the scenarios present a similarity in the area usage and accuracy. The results in the AF system present most values below 15 slices, just the scenarios 6 and 7 with approximately 135 slices, similar to recent literature. Figure 3 - Relative Error of the HPR and HPC Scenarios with 500 Points. Analysis of the Results

Approximation of Hyperbolic Tangent Activation Function ... · Approximation of Hyperbolic Tangent Activation Function Using Hybrid Methods Maicon A. Sartin ... Approximations Error_Max

Embed Size (px)

Citation preview

Page 1: Approximation of Hyperbolic Tangent Activation Function ... · Approximation of Hyperbolic Tangent Activation Function Using Hybrid Methods Maicon A. Sartin ... Approximations Error_Max

Approximation of Hyperbolic TangentActivation Function Using Hybrid Methods

Maicon A. Sartin - Universidade do Estado de Mato Grosso (UNEMAT), Brazil.Alexandre C. R. da Silva - Universidade Estadual Paulista (UNESP), Brazil.

[email protected], [email protected]

The contribution of this work is the ap-proximation of a nonlinear function usedin ANN, the popular hyperbolic tangent(HT) activation function (AF). The systemarchitecture is composed of several sce-narios that provide a tradeoff of perfor-mance, precision and area used in FPGA.The results are compared in different sce-narios and with current literature on erroranalysis, area and system performance.

Abstract

The HT and sigmoid functions both pro-duce a curve with an “S” shape. HT con-tains values (±) and the output is be-tween [-1,1]. The behavior of the AF isnonlinear and has a steeper curve beforesaturation of the two ends. Four featurescan be observed on the HT: (i) there issymmetry between the y axis; (ii) For verylarge values of x, Th(x) → ±1; (iii) thecentral part is near a linear equation andthe variation is greater; (iv) The output(Th (x)) is equal to its input values for xnear zero.th(x) = 1− e−αx1 + e−αx

Table 1 - Analyzed Scenarios.N. Scenarios1 HPR of 180 Elements2 HPR of 212 Elements3 HPR of 314 Elements4 HPR of 340 Elements5 HPR of 404 Elements6 HPC of 180 Elements7 HPC of 212 Elements8 HPC of 340 Elements9 HPC of 404 Elements

Basic Concepts

Table 2 - Errors Absolute and Relative FoundApproximations Error_Max Error_Ave Rel_AveSc. 1 (180) 4.18× 10−3 1.05× 10−3 1.24× 10−3Sc. 2 (212) 4.18× 10−3 1.03× 10−3 1.20× 10−3Sc. 3 (314) 3.30× 10−3 6.80× 10−4 8.43× 10−4Sc. 4 (340) 3.30× 10−3 7.18× 10−4 8.99× 10−4Sc. 5 (404) 3.23× 10−3 6.80× 10−4 8.69× 10−4Sc. 6 (180) 5.94× 10−3 2.75× 10−3 3.04× 10−3Sc. 7 (212) 5.94× 10−3 2.75× 10−3 3.04× 10−3Sc. 8 (340) 5.94× 10−3 2.36× 10−3 2.72× 10−3Sc. 9 (404) 5.94× 10−3 2.28× 10−3 2.67× 10−3Comb(Tommiska,03) 3.90× 10−3 1.70× 10−3 -Hybrid(Meher,10) 2.00× 10−2 1.72× 10−2 -Hybrid(Bajger;Omondi,08) 4.61× 10−4 1.35× 10−4 1.38× 10−3

Analysis of the Results

This paper presented the implementationof a system for approximating a HT AFinto a reconfigurable device. Scenarios1 to 5 are good options in the precisionHT AF to the FPGA. The scenarios 6 to9 don’t need BRAM and the precision isrelatively compromised with the previousscenarios, but has the best tradeoff.

Conclusion

The authors would like to thank the support of UNEMAT, UNESP andPPGEE, LPSSD, CAPES and CNPQ - process (309023/2012-2).Acknowledgements

HPR (Hybrid with PWL and RALUT) and HPC (Hybrid with PWL andCombinational) methods use division into parts (PWL) with the goalof acquire high precision and an amount of elements adapted to thevariation of interval. Combinational techniques and RALUT can reducehardware resources with suitable. In the HPR hardware, the mapping ismade from amount of addressing bits related with the scenario interval.To make mapping in the HPC hardware each interval contains a sum ofproducts (SOP) to each output bit. SOP is made based in the amount ofelements in interval and simplified with the Quine-McCluskey algorithm.

Figure 1 - Hardware for Mapping the Outputs of the AF (HPR and HPC)

Proposed Methods for the Approximation of the HT

The system contains 500 inputs samples for the error analysis, area, andperformance in implementing the HT AF in hardware. With all samplesthe implementation of the scenarios were run in approximately 40 µs forSpartan 3E platform, with clock period of 20 ns.

Figure 2 - Approximation of the HT AF with 500 and 6 points for all scenariosThe scenarios (1 to 5) (HPR) present the best accuracy, when comparedwith combinational methods (Scenarios 6 to 9) (HPC). But the HPRscenarios need of dedicated memory (BRAM), different of HPC scenar-ios that have just Boolean expressions. Analyzing the tradeoff betweenarea and accuracy the scenario 9 is the best choose between all. Inthe results of the scenarios present a similarity in the area usage andaccuracy. The results in the AF system present most values below 15slices, just the scenarios 6 and 7 with approximately 135 slices, similarto recent literature.

Figure 3 - Relative Error of the HPR and HPC Scenarios with 500 Points.

Analysis of the Results