


# GldReLU

Golden Ratio ReLU (GldReLU) is a custom activation function for TensorFlow


[![PyPI version](https://img.shields.io/pypi/v/gldrelu)](https://pypi.org/project/gldrelu/)
[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)](https://www.python.org/)

Golden Ratio ReLU (GldReLU) is a custom activation function for TensorFlow
based on the Golden Ratio constant. It can be used in deep learning models
just like other activation, and is especially useful for deep networks in 
medical imaging and research applications.

---

$$
GldReLU(x) = \max(0, (\phi - 1))\cdot x
$$

where:

$$
\phi = \frac{1 + \sqrt{5}}{2} \approx 1.618
$$

so that:

$$
\phi - 1 \approx 0.618
$$




$$
\text{GldReLU}(x) =
\begin{cases} 
0.618 \, x, & \text{if } x > 0 \\[2mm]
0, & \text{if } x \leq 0
\end{cases}
$$


## Installation

pip install gldrelu
 
 
## Usage Example

### 1️ Using `"GldReLU"` as a string (no function import needed)

```python
import tensorflow as tf
import GldReLU  # registers GldReLU automatically

model = tf.keras.Sequential([
    tf.keras.layers.Dense(128, activation="GldReLU"),
    tf.keras.layers.Dense(10, activation="softmax")
])

model.summary()


###  Using the function directly

from GldReLU import GldReLU
import tensorflow as tf

model = tf.keras.Sequential([
    tf.keras.layers.Dense(128, activation=GldReLU),
    tf.keras.layers.Dense(10, activation="softmax")
])

model.summary()



If you use GldReLU in your research,  cite:

@article{lakshmi2025novel,
  title={A novel GldReLU activation function with enhanced RESNET50 for classification of X-ray images},
  author={Lakshmi, P Pankaja and Sivagami, M},
  journal={Neural Computing and Applications},
  volume={37},
  number={26},
  pages={21997--22028},
  year={2025},
  publisher={Springer}
}
