{"id":37717919,"url":"https://github.com/nikitadurasov/masksembles","last_synced_at":"2026-01-16T13:29:45.488Z","repository":{"id":41232627,"uuid":"344270296","full_name":"nikitadurasov/masksembles","owner":"nikitadurasov","description":"Official repository for the paper \"Masksembles for Uncertainty Estimation\" (CVPR 2021).","archived":false,"fork":false,"pushed_at":"2025-11-09T13:32:03.000Z","size":285,"stargazers_count":102,"open_issues_count":12,"forks_count":16,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-11-09T15:14:39.929Z","etag":null,"topics":["computer-vision","deep-learning","out-of-distribution-detection","paper","tensorflow","torch","uncertainty-estimation","uncertainty-neural-networks","uncertainty-quantification"],"latest_commit_sha":null,"homepage":"https://www.norange.io/projects/masksembles/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikitadurasov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-03-03T21:35:47.000Z","updated_at":"2025-11-09T13:32:07.000Z","dependencies_parsed_at":"2024-02-08T20:34:23.385Z","dependency_job_id":"40d96a6d-4440-48d4-b674-3b6a43fa001d","html_url":"https://github.com/nikitadurasov/masksembles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nikitadurasov/masksembles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitadurasov%2Fmasksembles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitadurasov%2Fmasksembles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitadurasov%2Fmasksembles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitadurasov%2Fmasksembles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikitadurasov","download_url":"https://codeload.github.com/nikitadurasov/masksembles/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitadurasov%2Fmasksembles/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","deep-learning","out-of-distribution-detection","paper","tensorflow","torch","uncertainty-estimation","uncertainty-neural-networks","uncertainty-quantification"],"created_at":"2026-01-16T13:29:45.411Z","updated_at":"2026-01-16T13:29:45.483Z","avatar_url":"https://github.com/nikitadurasov.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Masksembles for Uncertainty Estimation\n\n\u003c!-- ---\nOfficial implementation of Masksembles approach from the paper \"Masksembles for Uncertainty Estimation\" by \nNikita Durasov, Timur Bagautdinov, Pierre Baque, Pascal Fua (CVPR 2021).\n\n--- --\u003e\n\n![Project Page](./images/mask_logo.png)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/masksembles/\"\u003e\n    \u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/masksembles.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pepy.tech/project/masksembles\"\u003e\n    \u003cimg alt=\"PyPI Downloads\" src=\"https://static.pepy.tech/badge/masksembles\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pepy.tech/project/masksembles\"\u003e\n    \u003cimg alt=\"Monthly Downloads\" src=\"https://static.pepy.tech/badge/masksembles/month\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/masksembles/\"\u003e\n    \u003cimg alt=\"Python Versions\" src=\"https://img.shields.io/pypi/pyversions/masksembles\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/nikitadurasov/masksembles/stargazers\"\u003e\n    \u003cimg alt=\"GitHub stars\" src=\"https://img.shields.io/github/stars/nikitadurasov/masksembles?style=social\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/nikitadurasov/masksembles/network/members\"\u003e\n    \u003cimg alt=\"GitHub forks\" src=\"https://img.shields.io/github/forks/nikitadurasov/masksembles?style=social\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/nikitadurasov/masksembles/issues\"\u003e\n    \u003cimg alt=\"Issues\" src=\"https://img.shields.io/github/issues/nikitadurasov/masksembles\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/nikitadurasov/masksembles/blob/main/LICENSE\"\u003e\n    \u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/nikitadurasov/masksembles\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\n### [Project Page](https://nikitadurasov.github.io/projects/masksembles/) | [Paper](https://arxiv.org/abs/2012.08334) | [Video Explanation](https://www.youtube.com/watch?v=YWKVdn3kLp0)\n\n[![Open Masksembles in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/nikitadurasov/masksembles/blob/main/notebooks/MNIST_Masksembles.ipynb)\n\n\u003c!-- \u003cp align=\"center\"\u003e\n  \u003cimg style=\"border-radius: 30px\" src=\"https://raw.githubusercontent.com/nikitadurasov/masksembles/main/images/transition.gif\" /\u003e\n\u003c/p\u003e --\u003e\n\n\n## Why Masksembles?\n\n**Uncertainty Estimation** is one of the most important and critical tasks in the area of modern neural networks and deep learning.\nThere is a long list of potential applications of uncertainty: safety-critical applications, active learning, domain adaptation, \nreinforcement learning and etc.\n\n**Masksembles** is a **simple** and **easy-to-use** drop-in method with performance on par with Deep Ensembles at a fraction of the cost.\nIt makes *almost* no changes in your original model and requires only to add special intermediate layers. \n\n[![Watch the video](https://img.youtube.com/vi/YWKVdn3kLp0/maxresdefault.jpg)](https://youtu.be/YWKVdn3kLp0)\n\n### [Watch this video on YouTube](https://youtu.be/YWKVdn3kLp0)\n\n## Installation\n\nTo install this package, use:\n\n```bash\npip install masksembles\n```\nor\n```bash\npip install git+http://github.com/nikitadurasov/masksembles\n```\n\nIn addition, Masksembles requires installing at least one of the backends: torch or tensorflow2 / keras.\nPlease follow official installation instructions for [torch](https://pytorch.org/) or [tensorflow](https://www.tensorflow.org/install)\naccordingly.\n\n\n## Usage \n\n[comment]: \u003c\u003e (In masksembles module you could find implementations of \"Masksembles{1|2|3}D\" that)\n\n[comment]: \u003c\u003e (support different shapes of input vectors \u0026#40;1, 2 and 3-dimentional accordingly\u0026#41;)\n\nThis package provides implementations for `Masksembles{1|2|3}D` layers in `masksembles.{torch|keras}` \nwhere `{1|2|3}` refers to dimensionality of input tensors (1-, 2- and 3-dimensional \naccordingly).\n\n* `Masksembles1D`: works with 1-dim inputs,`[B, C]` shaped tensors\n* `Masksembles2D`: works with 2-dim inputs,`[B, H, W, C]` (keras) or `[B, C, H, W]` (torch) shaped tensors\n* `Masksembles3D` : TBD\n\nIn a Nutshell, Masksembles applies binary masks to inputs via multiplying them both channel-wise. For more efficient\nimplementation we've followed approach similar to [this](https://arxiv.org/abs/2002.06715) one. Therefore, after inference\n`outputs[:B // N]` - stores results for the first submodel, `outputs[B // N : 2 * B // N]` - for the second and etc.  \n### Torch \n\n```python \nimport torch\nfrom masksembles.torch import Masksembles1D\n\nlayer = Masksembles1D(10, 4, 2.)\nlayer(torch.ones([4, 10]))\n```\n```bash\ntensor([[0., 1., 0., 0., 1., 0., 1., 1., 1., 1.],\n        [0., 0., 1., 1., 1., 1., 0., 0., 1., 1.],\n        [1., 0., 1., 1., 0., 0., 1., 0., 1., 1.],\n        [1., 0., 0., 1., 1., 1., 0., 1., 1., 0.]], dtype=torch.float64)\n\n```\n\n### Tensorflow / Keras\n\n```python \nimport tensorflow as tf \nfrom masksembles.keras import Masksembles1D\n\nlayer = Masksembles1D(4, 2.)\nlayer(tf.ones([4, 10]))\n```\n```bash\n\u003ctf.Tensor: shape=(4, 10), dtype=float32, numpy=\narray([[0., 1., 1., 0., 1., 1., 1., 0., 1., 0.],\n       [0., 1., 0., 1., 1., 0., 1., 1., 0., 1.],\n       [1., 1., 1., 1., 0., 0., 1., 0., 0., 1.],\n       [1., 0., 0., 1., 0., 1., 1., 0., 1., 1.]], dtype=float32)\u003e\n```\n\n### Model example\n```python \nimport tensorflow as tf \nfrom masksembles.keras import Masksembles1D, Masksembles2D\n\nmodel = keras.Sequential(\n    [\n        keras.Input(shape=input_shape),\n        layers.Conv2D(32, kernel_size=(3, 3), activation=\"elu\"),\n        Masksembles2D(4, 2.0),\n        layers.MaxPooling2D(pool_size=(2, 2)),\n     \n        layers.Conv2D(64, kernel_size=(3, 3), activation=\"elu\"),\n        Masksembles2D(4, 2.0),\n        layers.MaxPooling2D(pool_size=(2, 2)),\n     \n        layers.Flatten(),\n        Masksembles1D(4, 2.),\n        layers.Dense(num_classes, activation=\"softmax\"),\n    ]\n)\n```\n\n## Citation\nIf you found this work useful for your projects, please don't forget to cite it.\n```\n@inproceedings{Durasov21,\n  author = {N. Durasov and T. Bagautdinov and P. Baque and P. Fua},\n  title = {{Masksembles for Uncertainty Estimation}},\n  booktitle = CVPR,\n  year = 2021\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikitadurasov%2Fmasksembles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikitadurasov%2Fmasksembles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikitadurasov%2Fmasksembles/lists"}