A deep learning library for advanced neural network layers.
Project description
Mombai
A deep learning library for multi-activation neural network layers built on TensorFlow/Keras.
Mombai implements two families of layers that combine multiple activation functions in a single transformation:
- WAF (Weighted Activation Fusion): Applies multiple activations with learned per-branch affine transforms, then compresses via sum or average.
- MoA (Mixture of Activations): Input-dependent activation selection using attention mechanisms.
Installation
pip install mombai
Layers
WAFLayer
Weighted Activation Fusion. Each activation branch has its own learned scale and bias.
from mombai import WAFLayer
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, input_shape=(10,)),
WAFLayer(units=32, activations=['relu', 'swish', 'gelu'], compressor="sum"),
tf.keras.layers.Dense(1)
])
WAFLayerNorm / WAFLayerNormV2
WAF with normalization. WAFLayerNorm normalizes before activations (pre-norm), WAFLayerNormV2 normalizes after each activation branch (post-norm).
from mombai import WAFLayerNormV2
layer = WAFLayerNormV2(units=64, activations=['relu', 'gelu', 'swish'], compressor="avg")
MAXLayerWithAttention (MoA-USM)
Input-dependent gating via Dense + softmax. Each input sample gets its own activation mixture weights.
from mombai import MAXLayerWithAttention
layer = MAXLayerWithAttention(units=64, activations=['relu', 'swish', 'gelu', 'tanh', 'sigmoid'])
MAXLayerWithSelfAttention (MoA-GSM V1)
Self-attention over activation branches. Best for sequential data (T > 1).
from mombai import MAXLayerWithSelfAttention
layer = MAXLayerWithSelfAttention(units=32, activations=['relu', 'swish', 'gelu'])
MAXLayerWithSelfAttentionV2 (MoA-GSM V2)
Self-attention with two modes:
attention_mode="channel": Features attend to each other to produce gates. Best for non-sequential (tabular/image) data.attention_mode="temporal": Standard temporal self-attention. Best for sequential data.
from mombai import MAXLayerWithSelfAttentionV2
# For tabular/image data (most common)
layer = MAXLayerWithSelfAttentionV2(
units=64,
activations=['relu', 'swish', 'gelu', 'tanh', 'sigmoid'],
attention_mode="channel"
)
# For sequential data
layer = MAXLayerWithSelfAttentionV2(
units=64,
activations=['relu', 'swish', 'gelu'],
attention_mode="temporal"
)
Supported Activations
relu, sigmoid, tanh, softmax, softplus, softsign, elu, selu, swish, gelu, leaky_relu, relu6, hard_sigmoid, exponential, linear, log_softmax
Requirements
- Python >= 3.8
- TensorFlow >= 2.0
License
MIT License. See LICENSE for 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mombai-3.0.0.tar.gz.
File metadata
- Download URL: mombai-3.0.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d87f18c5b89854373c400cde400080e3f774036bb627107098cbcb214817531
|
|
| MD5 |
08cda4994ebeeb174cbb42434fd11355
|
|
| BLAKE2b-256 |
73b766e42d4c3e648284f19d39e10c6f19e9db3c06209d94d5161a080e64250b
|
File details
Details for the file mombai-3.0.0-py3-none-any.whl.
File metadata
- Download URL: mombai-3.0.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e742edc62b2afb4a173016e7ab31319ba12b9bb57f8aa15164389082420ac033
|
|
| MD5 |
e619da86bf66c7cc961307cd96288517
|
|
| BLAKE2b-256 |
99bb4b348771e623d973d8bb28950afd3f186eb76526f299e6f8b3301830f88f
|