{"id":14958673,"url":"https://github.com/alshedivat/meta-blocks","last_synced_at":"2025-10-06T00:38:55.450Z","repository":{"id":41060888,"uuid":"242857817","full_name":"alshedivat/meta-blocks","owner":"alshedivat","description":"A modular toolbox for meta-learning research with a focus on speed and reproducibility.","archived":false,"fork":false,"pushed_at":"2023-04-13T08:58:18.000Z","size":1853,"stargazers_count":125,"open_issues_count":0,"forks_count":9,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-09-25T03:47:16.323Z","etag":null,"topics":["api","benchmark","deep-learning","learning-to-learn","meta-learning","python","tensorflow","toolbox"],"latest_commit_sha":null,"homepage":"https://meta-blocks.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alshedivat.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}},"created_at":"2020-02-24T22:29:29.000Z","updated_at":"2025-07-30T08:55:42.000Z","dependencies_parsed_at":"2024-01-12T12:56:35.319Z","dependency_job_id":"e276068e-cf1c-492a-bcf8-c4dc6e2c4934","html_url":"https://github.com/alshedivat/meta-blocks","commit_stats":{"total_commits":145,"total_committers":3,"mean_commits":"48.333333333333336","dds":"0.24827586206896557","last_synced_commit":"6f6d93dfaab75766e8afdf9eb2fad17dc79218f2"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/alshedivat/meta-blocks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshedivat%2Fmeta-blocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshedivat%2Fmeta-blocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshedivat%2Fmeta-blocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshedivat%2Fmeta-blocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alshedivat","download_url":"https://codeload.github.com/alshedivat/meta-blocks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshedivat%2Fmeta-blocks/sbom","scorecard":{"id":186929,"data":{"date":"2025-08-11","repo":{"name":"github.com/alshedivat/meta-blocks","commit":"6f6d93dfaab75766e8afdf9eb2fad17dc79218f2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/13 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T19:57:23.709Z","repository_id":41060888,"created_at":"2025-08-16T19:57:23.709Z","updated_at":"2025-08-16T19:57:23.709Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278542673,"owners_count":26004060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api","benchmark","deep-learning","learning-to-learn","meta-learning","python","tensorflow","toolbox"],"created_at":"2024-09-24T13:17:48.042Z","updated_at":"2025-10-06T00:38:55.406Z","avatar_url":"https://github.com/alshedivat.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/alshedivat/meta-blocks/blob/master/docs/_static/img/meta-blocks-2d.png?raw=true\" alt=\"logo\" width=\"400px\" /\u003e\u003c/p\u003e\n\n\u003ch3 align=\"center\"\u003eA Modular Toolbox for Accelerating Meta-Learning Research :rocket:\u003c/h3\u003e\n\n---\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/meta-blocks)](https://pypi.org/project/meta-blocks/)\n[![PyPI Status Badge](https://badge.fury.io/py/meta-blocks.svg)](https://pypi.org/project/meta-blocks/)\n[![Build Status](https://travis-ci.org/alshedivat/meta-blocks.svg?branch=master)](https://travis-ci.org/alshedivat/meta-blocks)\n[![Documentation Status](https://readthedocs.org/projects/meta-blocks/badge/?version=latest)](https://meta-blocks.readthedocs.io/en/latest/?badge=latest)\n[![Coverage Status](https://coveralls.io/repos/github/alshedivat/meta-blocks/badge.svg?branch=master)](https://coveralls.io/github/alshedivat/meta-blocks?branch=master)\n[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/alshedivat/meta-blocks.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/alshedivat/meta-blocks/context:python)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n**MetaBlocks** is a modular toolbox for research, experimentation, and reproducible benchmarking of learning-to-learn algorithms.\nThe toolbox provides a flexible API for working with `MetaDatasets`, `TaskDistributions`, and `MetaLearners`.\nThe API fully decouples data processing, construction of learning tasks (and their distributions), adaptation algorithms, and model architectures, and makes it easy to experiment with different combinations of these basic building blocks as well as add new components to the growing ecosystem.\nAdditionally, the library features a [suite of benchmarks](benchmarks) that enable reproducibility.\nEverything is highly configurable through [hydra](https://hydra.cc/).\n\nThe library is **under active development**.\nThe latest documentation is available at: https://meta-blocks.readthedocs.io/.\n\n---\n\n## Installation\n\nMetaBlocks requires Python 3.5+ and TensorFlow 2.2+.\n\n### For typical use\n\nWe recommend using **pip** for installing the latest release of the library:\n```shell script\n$ pip install meta-blocks            # normal install\n$ pip install --upgrade meta-blocks  # or update if needed\n$ pip install --pre meta-blocks      # or include pre-release version for new features\n```\n\nAlternatively, to install the latest version from the `master` branch:\n```shell script\n$ git clone https://github.com/alshedivat/meta-blocks.git\n$ pip install meta-blocks\n```\n\n**Note:** to be able to access and run benchmarks, you will need to clone the repository.\n\n### For development and contributions\n\nYou can install additional development requirements as follows:\n```shell script\n$ pip install -r requirements/dev.txt\n```\n\nAlso, please make sure to install pre-commit hooks to ensure proper code style and formatting:\n```shell script\n$ pip install pre-commit      # install pre-commit\n$ pre-commit install          # install git hooks\n$ pre-commit run --all-files  # run pre-commit on all the files\n```\n\n---\n\n## Getting started \u0026 use cases\n\nYou can use the library as (1) a modular benchmarking suite or (2) a scaffold API for new learning-to-learn algorithms.\n\n### Benchmarking\n\nTo enable reproducible research, we maintain a suite of [benchmarks/](benchmarks/).\nTo run a benchmark, simply clone the repo, change your working directory to the corresponding benchmark, and execute a run script.\nFor example:\n```shell script\n$ git clone https://github.com/alshedivat/meta-blocks.git\n$ cd meta-blocks/benchmarks/omniglot\n$ ./fetch_data                    # fetches data for the benchmark\n$ ./run_classic_supervised.sh     # runs an experiment (train and eval routines in parallel)\n```\nFor more details, please refer to [benchmarks/README.md](benchmarks/README.md).\n\n### MetaBlocks API\n\n**MetaBlocks** provides multiple layers of API implemented as a hierarchy of Python classes.\nThe three major main components are `MetaDataset`, `TaskDistribution`, and `MetaLearner`:\n\n1. `MetaDataset` provides access to `Dataset` instances constructed from an underlying `DataSource`.\n   `Dataset` represents a collection of data tensors (e.g., in case of multi-class classification, it is a collection of input tensors, one for each class).\n2. `TaskDistribution` further builds on top of `MetaDataset` and provides access to `Task` instances that specify the semantics of a learning task.\n   E.g., a few-shot classification task provides access to non-overlapping support and query subsets of a `Dataset`.\n   Task distributions determine how tasks are sampled and constructed.\n   Currently, we support `supervised` and `self-supervised` tasks for few-shot classification.\n3. `MetaLearner` encapsulates a parametric model (your favorite neural net) and an adaptation algorithm used for adapting the model to new tasks.\n   Adaptation algorithms must use the API exposed by the `Task`.\n\n**Note:** decoupling tasks from datasets and (meta-)learning methods is one of the core advantages of meta-blocks over other libraries.\n   \nBelow are the components currently supported by the library:\n\n\u003ctable\u003e\n\u003cthead\u003e\n\u003cth\u003eComponent\u003c/th\u003e\n\u003cth colspan=\"4\"\u003eSupported Instances\u003c/th\u003e\n\u003c/thead\u003e\n\u003ctr\u003e\n\u003ctd\u003eMetaDataset\u003c/td\u003e\n\u003ctd\u003eOmniglot\u003c/td\u003e\n\u003ctd\u003eMiniImageNet\u003c/td\u003e\n\u003ctd colspan=\"2\"\u003e...\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eTaskDistribution\u003c/td\u003e\n\u003ctd\u003eClassic supervised\u003c/td\u003e\n\u003ctd\u003eLimited supervised\u003c/td\u003e\n\u003ctd\u003eSelf-supervised\u003c/td\u003e\n\u003ctd\u003e...\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eMetaLearner\u003c/td\u003e\n\u003ctd\u003eMAML [1]\u003c/td\u003e\n\u003ctd\u003eReptile [2]\u003c/td\u003e\n\u003ctd\u003ePrototypical Networks [3]\u003c/td\u003e\n\u003ctd\u003e...\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n#### Adding your own meta-datasets\n\nTo add your own meta-datasets, you need to subclass `MetaDataset` and implement a few methods.\n\n[TODO: provide a detailed walk-through example.]\n\nIf the full data used to construct the meta-dataset is light and easily fits in the memory, you can follow [the implementation of Omniglot](meta_blocks/datasets/omniglot.py).\nIf the dataset is too large or requires some heavy preprocessing, the best way is to use `tf.data.Dataset` API.\nAs a starting point, you can follow the [miniImageNet implementation](meta_blocks/datasets/miniimagenet.py).\n\n\n#### Adding your own meta-learners\n\nTo add your own meta-learning algorithms, you need to subclass `MetaLearner` and implement two methods: `_get_adapted_model` (must return an adapted model instance) and `_build_adaptation` (must build a part of the computation graph that adapts the model).\nExample: [prototype-based adaptation](meta_blocks/adaptation/proto.py) builds prototypes from the support set inside `_build_adaptation` method and returns a model with the corresponding prototypes when `_get_adapted_model` is called.\n\n[TODO: provide a detailed walk-through example.]\n\n---\n\n## Citation\n\nIf you use meta-blocks for research, please cite it as follows.\n\n```\n@misc{metablocks,\n  title={MetaBlocks: A modular toolbox for meta-learning research with a focus on speed and reproducibility.},\n  year={2020},\n  publisher={GitHub},\n  journal={GitHub repository},\n  howpublished={\\url{https://github.com/alshedivat/meta-blocks}},\n}\n```\n\n---\n\n## Related projects\n\nA few notable related projects:\n\n| Project | Description |\n| ------- | ----------- |\n| [Torchmeta](https://github.com/tristandeleu/pytorch-meta) | A PyTorch library that implements multiple few-shot learning methods. |\n| [learn2learn](https://github.com/learnables/learn2learn)  | A PyTorch library that supports meta-RL. |\n\n\n## References\n\n[1] Finn, C., Abbeel, P. and Levine, S. Model-agnostic meta-learning for fast adaptation of deep networks. ICML 2017.\n\n[2] Nichol, A., Achiam, J. and Schulman, J. On first-order meta-learning algorithms. arXiv preprint arXiv:1803.02999.\n\n[3] Snell, J., Swersky, K. and Zemel, R. Prototypical networks for few-shot learning. NeurIPS 2017.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falshedivat%2Fmeta-blocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falshedivat%2Fmeta-blocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falshedivat%2Fmeta-blocks/lists"}