{"id":19042834,"url":"https://github.com/omni-us/narchi","last_synced_at":"2025-04-23T22:28:55.142Z","repository":{"id":57444928,"uuid":"264394953","full_name":"omni-us/narchi","owner":"omni-us","description":"A neural network architecture definition package","archived":false,"fork":false,"pushed_at":"2024-10-07T07:42:04.000Z","size":7181,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-16T10:31:37.669Z","etag":null,"topics":["ai","artificial-intelligence","configuration","data-science","deep-learning","machine-learning","neural-networks","pytorch"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/omni-us.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.rst","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}},"created_at":"2020-05-16T08:43:04.000Z","updated_at":"2024-10-07T07:41:14.000Z","dependencies_parsed_at":"2024-11-08T22:39:19.341Z","dependency_job_id":"5ce0a99d-e056-4591-be06-dcdd249a8261","html_url":"https://github.com/omni-us/narchi","commit_stats":{"total_commits":77,"total_committers":1,"mean_commits":77.0,"dds":0.0,"last_synced_commit":"55eacc273e61ab0166b5692204a20ab756b92e4c"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omni-us%2Fnarchi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omni-us%2Fnarchi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omni-us%2Fnarchi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omni-us%2Fnarchi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omni-us","download_url":"https://codeload.github.com/omni-us/narchi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250525803,"owners_count":21445080,"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","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":["ai","artificial-intelligence","configuration","data-science","deep-learning","machine-learning","neural-networks","pytorch"],"created_at":"2024-11-08T22:39:08.340Z","updated_at":"2025-04-23T22:28:55.115Z","avatar_url":"https://github.com/omni-us.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://circleci.com/gh/omni-us/narchi.svg?style=svg\n    :target: https://circleci.com/gh/omni-us/narchi\n.. image:: https://codecov.io/gh/omni-us/narchi/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/omni-us/narchi\n.. image:: https://sonarcloud.io/api/project_badges/measure?project=omni-us_narchi\u0026metric=alert_status\n    :target: https://sonarcloud.io/dashboard?id=omni-us_narchi\n.. image:: https://badge.fury.io/py/narchi.svg\n    :target: https://badge.fury.io/py/narchi\n.. image:: https://img.shields.io/badge/contributions-welcome-brightgreen.svg\n    :target: https://github.com/omni-us/narchi\n\n\nnarchi - A neural network architecture definition package\n=========================================================\n\n`narchi` is as python package that provides functionalities for defining neural\nnetwork architectures in an implementation independent way. It is intended\nto make network architectures highly configurable while also making the task\neasier.\n\n\nMain features\n-------------\n\n- Network architectures are written in `jsonnet format\n  \u003chttps://jsonnet.org/\u003e`__, which provides useful features like input\n  parameters and functions to define repeated blocks.\n\n- The shapes of the tensors internal to the networks are automatically deduced\n  by propagating the shapes of the inputs, thus requiring less effort and being\n  less error prone.\n\n- Propagation of shapes is done using symbolic arithmetic which makes it\n  simple to understand relationships between inputs and the derived shapes.\n\n- Architecture files can reference other architecture files, thus making this\n  approach modular.\n\n- A command line tool is included to validate jsonnet architecture files and to\n  create detailed diagrams of the respective network architectures.\n\n- Several `examples \u003chttps://github.com/omni-us/narchi/tree/master/examples\u003e`_\n  intended to illustrate different features supported.\n\n- Includes basic implementations that allows to instantiate pytorch modules:\n\n  * Instantiation only requires a jsonnet architecture file.\n  * No need to write module classes or forward function for each new architecture.\n  * One basic implementation that supports instatiating several of the examples.\n  * A second example that supports packed 1d and 2d sequences which illustrates the implementation independent nature of the architecture files.\n\n\nTeaser example\n--------------\n\nHere you can see an example that illustrates what `narchi` provides. The example\nis for resnet18 as implemented in torchvision, though bare in mind that the\npotential of `narchi` is the ease of configurability of network architectures, not\nthe reimplementation of existing architectures.\n\nInstantiating a pytorch module from the architecture file can be easily done as\nfollows.\n\n.. code-block:: PYTHON\n\n   from narchi.instantiators.pytorch import StandardModule\n   module = StandardModule('resnet.jsonnet',\n                           state_dict='resnet18-5c106cde.pth',\n                           cfg={'ext_vars': {\"num_blocks\": [2, 2, 2, 2]}})\n\nCreating a diagram of the architecture requires a single command like the following.\n\n.. code-block:: BASH\n\n   narchi_cli.py render \\\n     --ext_vars '{\"num_blocks\": [2, 2, 2, 2]}' \\\n     --nested_depth 4 \\\n     resnet.jsonnet \\\n     resnet18.pdf\n\nBelow you can see a small part of the rendered diagram of the start of the\nfirst downsample layer of resnet18.\n\n.. image:: imgs/resnet_crop.png\n   :width: 500\n\nThe part of the json that generated the previous crop of the architecture\ndiagram can be seen below. Note that information of the shapes is not included,\nsince these are derived automatically.\n\n.. code-block:: JSON\n\n   {\n     \"_class\": \"Sequential\",\n     \"_id\": \"layer2\",\n     \"blocks\": [\n       {\n         \"_class\": \"Group\",\n         \"_name\": \"ResBlock\",\n         \"blocks\": [\n           {\n             \"_class\": \"Identity\",\n             \"_id\": \"ident\"\n           },\n           {\n             \"_class\": \"Conv2d\",\n             \"_id\": \"conv1\",\n             \"bias\": false,\n             \"dilation\": 1,\n             \"kernel_size\": 3,\n             \"output_size\": 128,\n             \"padding\": 1,\n             \"stride\": 2\n           },\n           {\n             \"_class\": \"BatchNorm2d\",\n             \"_id\": \"bn1\"\n           },\n           {\n             \"_class\": \"Sequential\",\n             \"_id\": \"downsample\",\n             \"blocks\": [\n               {\n                 \"_class\": \"Conv2d\",\n                 \"bias\": false,\n                 \"kernel_size\": 1,\n                 \"output_size\": 128,\n                 \"padding\": 0,\n                 \"stride\": 2\n               },\n               {\n                 \"_class\": \"BatchNorm2d\"\n               }\n             ]\n           },\n           {\"...\": \"...\"}\n         ],\n         \"graph\": [\n           \"ident -\u003e conv1 -\u003e bn1 -\u003e relu1 -\u003e conv2 -\u003e bn2 -\u003e add -\u003e relu2\",\n           \"ident -\u003e downsample -\u003e add\"\n         ],\n         \"input\": \"ident\",\n         \"output\": \"relu2\"\n       }\n     ]\n   }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomni-us%2Fnarchi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomni-us%2Fnarchi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomni-us%2Fnarchi/lists"}