konsa15 commited on
Commit
f6b8fd7
verified
1 Parent(s): bf6c37b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +78 -1
README.md CHANGED
@@ -7,4 +7,81 @@ sdk: static
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  pinned: false
8
  ---
9
 
10
+ <div align="center">
11
+ <h1>Adaptive Parametric Activation </h1>
12
+
13
+ [Konstantinos Panagiotis Alexandridis](https://kostas1515.github.io/)<sup>1</sup>,
14
+ [Jiankang Deng](https://jiankangdeng.github.io/)<sup>1</sup>,
15
+ [Anh Nguyen](https://cgi.csc.liv.ac.uk/~anguyen/)<sup>2</sup>,
16
+ [Shan Luo](https://shanluo.github.io/)<sup>3</sup>,
17
+
18
+ <sup>1</sup> Huawei Noah's Ark Lab,
19
+ <sup>2</sup> University of Liverpool,
20
+ <sup>3</sup> King's College London
21
+
22
+ [![Static Badge](https://img.shields.io/badge/ECCV_2024-APA-blue)](https://link.springer.com/chapter/10.1007/978-3-031-72949-2_26)
23
+ [![Static Badge](https://img.shields.io/badge/arxiv-2407.08567-blue)](https://arxiv.org/pdf/2407.08567)
24
+ [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/adaptive-parametric-activation/long-tail-learning-on-places-lt)](https://paperswithcode.com/sota/long-tail-learning-on-places-lt?p=adaptive-parametric-activation)
25
+ [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/adaptive-parametric-activation/instance-segmentation-on-lvis-v1-0-val)](https://paperswithcode.com/sota/instance-segmentation-on-lvis-v1-0-val?p=adaptive-parametric-activation)
26
+ [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/adaptive-parametric-activation/long-tail-learning-on-imagenet-lt)](https://paperswithcode.com/sota/long-tail-learning-on-imagenet-lt?p=adaptive-parametric-activation)
27
+ [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/adaptive-parametric-activation/long-tail-learning-on-inaturalist-2018)](https://paperswithcode.com/sota/long-tail-learning-on-inaturalist-2018?p=adaptive-parametric-activation)
28
+
29
+ </div>
30
+
31
+ <figure class="image text-center">
32
+ <img src="https://huggingface.co/spaces/konsa15/AGLU/resolve/main/assets/unified_activations_combined.jpg" alt="APA activation">
33
+ <figcaption> Figure 1: APA unifies most activation functions under the same formula.</figcaption>
34
+ </figure>
35
+
36
+ <h3>Abstract</h3>
37
+
38
+ The activation function plays a crucial role in model optimisation, yet the optimal choice remains unclear. For example, the Sigmoid activation is the de-facto activation in balanced classification tasks, however, in imbalanced classification, it proves inappropriate due to bias towards frequent classes. In this work, we delve deeper in this phenomenon by performing a comprehensive statistical analysis in the classification and intermediate layers of both balanced and imbalanced networks and we empirically show that aligning the activation function with the data distribution, enhances the performance in both balanced and imbalanced tasks. To this end, we propose the Adaptive Parametric Activation (APA) function, a novel and versatile activation function that unifies most common activation functions under a single formula. APA can be applied in both intermediate layers and attention layers, significantly outperforming the state-of-the-art on several imbalanced benchmarks such as ImageNet-LT, iNaturalist2018, Places-LT, CIFAR100-LT and LVIS and balanced benchmarks such as ImageNet1K, COCO and V3DET.
39
+ <h3>Definition</h3>
40
+
41
+ The Adaptive Parametric Activation APA is defined as: \\(APA(z,位,魏) = (位 exp(鈭捨簔) + 1) ^{\frac{1}{鈭捨粆}\\). APA unifies most activation functions under the same formula as shwon in Figure 1.
42
+
43
+ APA can be used insed the intermediate layers using Adaptive Generalised Linear Unit (AGLU): \\(AGLU(z,位,魏) = z APA(z,位,魏)\\).
44
+ The derivatives of AGLU with respect to 魏 (top), 位 (middle) and z (bottom) are shown in Figure 2:
45
+
46
+
47
+ <figure class="image text-center">
48
+ <img src="https://huggingface.co/spaces/konsa15/AGLU/resolve/main/assets/derivative_visualisations.jpg" alt="AGLU derivatives">
49
+ <figcaption> Figure 2: The derivatives of AGLU with respect to 魏 (top), 位 (middle) and z (bottom).</figcaption>
50
+ </figure>
51
+
52
+
53
+ <h3> Simple Code implementation </h3>
54
+
55
+ ```python
56
+ class Unified(nn.Module):
57
+ """Unified activation function module."""
58
+
59
+ def __init__(self, device=None, dtype=None) -> None:
60
+ """Initialize the Unified activation function."""
61
+ factory_kwargs = {"device": device, "dtype": dtype}
62
+ super().__init__()
63
+ lambda_param = torch.nn.init.uniform_(torch.empty(1, **factory_kwargs))
64
+ kappa_param = torch.nn.init.uniform_(torch.empty(1, **factory_kwargs))
65
+ self.softplus = nn.Softplus(beta=-1.0)
66
+ self.lambda_param = nn.Parameter(lambda_param)
67
+ self.kappa_param = nn.Parameter(kappa_param)
68
+
69
+ def forward(self, input: torch.Tensor) -> torch.Tensor:
70
+ """Compute the forward pass of the Unified activation function."""
71
+ l = torch.clamp(self.lambda_param, min=0.0001)
72
+ p = torch.exp((1 / l) * self.softplus((self.kappa_param * input) - torch.log(l)))
73
+ return p # for AGLU simply return p*input
74
+ ```
75
+
76
+ ## BibTeX
77
+
78
+ ```bibtex
79
+ @inproceedings{alexandridis2024adaptive,
80
+ title={Adaptive Parametric Activation},
81
+ author={Alexandridis, Konstantinos Panagiotis and Deng, Jiankang and Nguyen, Anh and Luo, Shan},
82
+ booktitle={European Conference on Computer Vision},
83
+ pages={455--476},
84
+ year={2024},
85
+ organization={Springer}
86
+ }
87
+ ```