Skip to main content
QUICK REVIEW

[Paper Review] Approximating Activation Functions

Nicholas Gerard Timmons, Andrew Rice|arXiv (Cornell University)|Jan 17, 2020
Machine Learning and AlgorithmsComputer Science20 references11 citations
TL;DR

This paper proposes fast, accurate approximations for the sigmoid and hyperbolic tangent activation functions used in neural networks, particularly in LSTMs. Using function approximation techniques, the authors develop safe and ranged approximations that reduce training time by 10–37% on CPU and 20–53% with input domain restrictions, outperforming existing implementations in Theano and Word2Vec.

ABSTRACT

ReLU is widely seen as the default choice for activation functions in neural networks. However, there are cases where more complicated functions are required. In particular, recurrent neural networks (such as LSTMs) make extensive use of both hyperbolic tangent and sigmoid functions. These functions are expensive to compute. We used function approximation techniques to develop replacements for these functions and evaluated them empirically on three popular network configurations. We find safe approximations that yield a 10% to 37% improvement in training times on the CPU. These approximations were suitable for all cases we considered and we believe are appropriate replacements for all networks using these activation functions. We also develop ranged approximations which only apply in some cases due to restrictions on their input domain. Our ranged approximations yield a performance improvement of 20% to 53% in network training time. Our functions also match or considerably out perform the ad-hoc approximations used in Theano and the implementation of Word2Vec.

Motivation & Objective

  • To reduce the computational cost of expensive activation functions like sigmoid and tanh in neural networks.
  • To develop practical, empirically validated approximations that maintain model accuracy while improving training speed.
  • To provide drop-in replacements for standard activation functions in machine learning libraries.
  • To evaluate the impact of approximations on training and inference performance across multiple network architectures.
  • To demonstrate that approximations outperform existing ad-hoc implementations in popular frameworks like Theano and Word2Vec.

Proposed method

  • Proposed two safe approximations: sigm_fastexp_512 for sigmoid and tanh_pade_4_4 for tanh, using rational and exponential approximations.
  • Developed ranged approximations that apply only within restricted input domains to achieve higher performance gains.
  • Used empirical benchmarking on three popular neural network architectures to evaluate training and inference time improvements.
  • Evaluated approximations using CPU-based training and inference workloads to validate performance gains.
  • Implemented and open-sourced the approximations in Julia's Flux library, with validation in TensorFlow via performance comparison.
  • Validated approximations by measuring training time, loss, and convergence across multiple models and datasets.

Experimental results

Research questions

  • RQ1Can function approximation techniques be effectively applied to sigmoid and tanh activation functions to reduce training time without harming model accuracy?
  • RQ2How do the proposed safe and ranged approximations compare to existing approximations in Theano and Word2Vec in terms of speed and accuracy?
  • RQ3What is the performance impact of these approximations on real-world neural network architectures like LSTMs and feedforward networks?
  • RQ4To what extent do approximations affect training convergence and loss stability?
  • RQ5Can these approximations be effectively integrated into mainstream machine learning libraries as drop-in replacements?

Key findings

  • The safe approximations sigm_fastexp_512 and tanh_pade_4_4 reduced training time by 10% to 37% across all tested networks without degrading model accuracy.
  • The ranged approximations achieved performance improvements of 20% to 53% in training time, though they are restricted to specific input domains.
  • The approximations outperformed the ad-hoc approximations used in Theano and Word2Vec in both speed and training stability.
  • Training loss remained stable or improved with the new approximations, indicating no negative impact on model convergence.
  • The approximations were effective not only for training but also for inference, suggesting broad applicability.
  • Empirical evaluation confirmed that the approximations are viable drop-in replacements for standard activation functions in machine learning libraries.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.