Skip to main content

APEC (Asymmetric Parametric Exponential Curvature) activation function.

Project description

APEC and MAPEC Activation Functions for Neural Networks

Overview

This repository introduces two novel activation functions, APEC (Asymmetric Parametric Exponential Curvature) and its variant MAPEC (Multiplicative APEC), designed for deep learning models to capture complex patterns with improved performance. Functions have been tested on the CIFAR-100 dataset (results included) and on some of my experimental models (results not included).

Installation

pip install apec-afn

Activation Functions

  • APEC: Offers a balance between flexibility and performance, as demonstrated by the improvement over traditional functions on CIFAR-100.
  • MAPEC: An extension of APEC with an additional multiplicative term, allowing for an even richer model expressiveness and an observed faster convergence (up to 15%).

Mathematical Formulation

APEC (Asymmetric Parametric Exponential Curvature)

APEC

APEC is designed to introduce a non-linear response with an adjustable curvature, defined by: $$f(x) = a + \frac{b - x}{(g - \exp(-x)) + \epsilon}$$

  • Initialization: Parameters a and b are initialized with a normal distribution of zero mean and a standard deviation of 0.35. Parameter g is initialized with a mean of -1.375 and a standard deviation of 0.35.
  • Constraints: The default constraints for a, b, and g are [-2.0, +2.0], [-2.5, +2.5], and [-2.5, -0.25], respectively.
  • Stability: A small constant eps (1.0e-5) is added to prevent division by zero.

MAPEC (Multiplicative Asymmetric Parametric Exponential Curvature)

MAPEC

MAPEC extends APEC by adding a multiplicative term, enhancing its flexibility: $$f(x) = a + \frac{b - x}{g - \exp(-x)} + (x \cdot d)$$

  • Initialization: Parameters a, b, and d are initialized to 0.0, and g is initialized to -1.0.
  • Constraints: There are no constraints on the parameters for MAPEC, allowing for a fully adaptive response.

These functions aim to provide enhanced flexibility and adaptability for neural networks, particularly beneficial for complex pattern recognition tasks.

Usage

To evaluate a model with a specific activation function on CIFAR-100 and plot training loss*, use:

python scripts/eval_cifar100.py --activation APEC --plot-loss

* Plotting training loss requires self-projection package to be installed.

Results

Evaluation results on CIFAR-100:

Activation Average Loss Accuracy
APEC 2.2235 43%
*MAPEC 20e 2.3301 42%
*MAPEC 15e 2.2509 42%
Mish 2.2704 43%
SELU 2.2674 42%
PReLU 2.2759 42%
ReLU 2.3933 39%

APEC leads to the best performance, closely followed by Mish and SELU. MAPEC leads to the faster convergence with performance closely to APEC.

* Results provided for training with MAPEC activation for 20 and 15 epochs respectively.

You could look at training loss plots here.

CIFAR-100 Evaluation Script

Included in this repository is an evaluation script for the CIFAR-100 dataset.

Use the following command to see available options:

python scripts/eval_cifar100.py --help

Contributing

Contributions and suggestions are welcome! Feel free to fork the repository, open issues, and submit pull requests.

License

APEC is released under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apec-afn-0.1.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

apec_afn-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file apec-afn-0.1.1.tar.gz.

File metadata

  • Download URL: apec-afn-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for apec-afn-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7127e11f0549ef06ecb51104fbcf9227b4f6ba43ce4407491b3f8ac31247ce6a
MD5 62a76ff5bac10256b8e101ff8f492678
BLAKE2b-256 904021499148c6a015294db44a3359913e7384ad6154ef8c328b25c43948cee4

See more details on using hashes here.

File details

Details for the file apec_afn-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: apec_afn-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for apec_afn-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17c7cf2726f445cce6eb4b6463f74a472c78616f36b404f67623e89622021bb5
MD5 45674c9803f3e0ad73b33bcf6c230130
BLAKE2b-256 22f85d049017313b66946da31aa8b3f97fbb7800e8b502890a48080d57ebeda6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page