{"id":23673,"library":"entmax","title":"entmax","description":"A family of sparse alternatives to softmax, including entmax, sparsemax, normmax, and budget, with corresponding loss functions. Current version: 1.3. Release cadence is irregular, with updates as needed for bug fixes and new activations.","status":"active","version":"1.3","language":"python","source_language":"en","source_url":"https://github.com/deep-spin/entmax","tags":["entmax","sparsemax","sparse-activation","deep-learning","pytorch"],"install":[{"cmd":"pip install entmax","lang":"bash","label":"Default install"}],"dependencies":[],"imports":[{"note":"Official import path for the entmax loss function.","symbol":"entmax_loss","correct":"from entmax import entmax_loss"},{"note":"Official import path for the Sparsemax activation layer.","symbol":"Sparsemax","correct":"from entmax import Sparsemax"}],"quickstart":{"code":"import torch\nfrom entmax import entmax15, entmax_bisect\n\nx = torch.randn(2, 5)\ny = entmax15(x, dim=-1)\nprint(y)\nz = entmax_bisect(x, alpha=1.5, dim=-1)\nprint(z)","lang":"python","description":"Apply entmax-1.5 activation and the generic bisection-based entmax function."},"warnings":[{"fix":"Install PyTorch first: pip install torch. Then proceed with pip install entmax.","message":"entmax 1.x requires PyTorch to be installed before installation. Attempting to install entmax without torch will fail. Use conda or pip to install PyTorch first.","severity":"gotcha","affected_versions":"<=1.3"},{"fix":"Use entmax15 or Sparsemax for standard alphas; use bisection only for custom alphas.","message":"The bisection-based functions (entmax_bisect, etc.) are slower than the closed-form variants. They are intended for non-standard alpha values (not 1.5 or 2).","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Migrate to entmax15 (alpha=1.5) or Sparsemax (alpha=2).","message":"The 'alpha' parameter in some older functions is deprecated; use the specific entmax15 or Sparsemax functions instead.","severity":"deprecated","affected_versions":"<=1.2"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install PyTorch first: pip install torch. Then install entmax.","cause":"entmax depends on PyTorch but does not declare it as a dependency; install fails if torch is missing.","error":"ModuleNotFoundError: No module named 'torch'"},{"fix":"Ensure you are using a compatible device. The library supports both CPU and GPU; if you don't need GPU, ignore warnings.","cause":"entmax operations may be slower on CPU; but the library works on CPU. This error appears if CUDA-specific code is called incorrectly.","error":"RuntimeError: [...] torch.cuda.is_available() false"},{"fix":"Upgrade: pip install --upgrade entmax. Then use from entmax import entmax_loss.","cause":"Older versions (pre-1.3) may not include entmax_loss; or import path changed.","error":"ImportError: cannot import name 'entmax_loss' from 'entmax'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}