Activations Plus is a Python package designed to provide a collection of activation functions which are not implemented in PyTorch.
- Entmax: Sparse activation function for probabilistic models.
- Sparsemax: Sparse alternative to softmax.
some experimental features:
To install the package, use pip:
pip install activations-plus
Import and use any activation function in your PyTorch models:
import torch
from activations_plus.sparsemax import Sparsemax
from activations_plus.entmax import Entmax
# Example with Sparsemax
sparsemax = Sparsemax()
x = torch.tensor([[1.0, 2.0, 3.0], [1.0, 2.0, -1.0]])
output_sparsemax = sparsemax(x)
print("Sparsemax Output:", output_sparsemax)
# Example with Entmax
entmax = Entmax(alpha=1.5)
output_entmax = entmax(x)
print("Entmax Output:", output_entmax)
These examples demonstrate how to use Sparsemax and Entmax activation functions in PyTorch models.
Comprehensive documentation is available documentation.
- Entmax: Sparse activation function for probabilistic models. Reference Paper
- Sparsemax: Sparse alternative to softmax for probabilistic outputs. Reference Paper
Contributions are welcome! Please read the CONTRIBUTING.md file for guidelines.
To run the tests, use the following command:
pytest tests/
This project is licensed under the MIT License. See the LICENSE file for details.
Special thanks to the contributors and the open-source community for their support.