{"id":15066191,"url":"https://github.com/dalmia/siren","last_synced_at":"2025-04-06T11:07:53.617Z","repository":{"id":37222283,"uuid":"273587494","full_name":"dalmia/siren","owner":"dalmia","description":"PyTorch implementation of Sinusodial Representation networks (SIREN)","archived":false,"fork":false,"pushed_at":"2022-12-08T06:21:22.000Z","size":7307,"stargazers_count":263,"open_issues_count":18,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T10:08:08.005Z","etag":null,"topics":["activation-functions","deep-learning","machine-learning","pytorch"],"latest_commit_sha":null,"homepage":"","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/dalmia.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}},"created_at":"2020-06-19T21:13:24.000Z","updated_at":"2024-08-23T21:24:06.000Z","dependencies_parsed_at":"2023-01-25T15:31:22.527Z","dependency_job_id":null,"html_url":"https://github.com/dalmia/siren","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalmia%2Fsiren","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalmia%2Fsiren/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalmia%2Fsiren/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalmia%2Fsiren/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalmia","download_url":"https://codeload.github.com/dalmia/siren/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471518,"owners_count":20944158,"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":["activation-functions","deep-learning","machine-learning","pytorch"],"created_at":"2024-09-25T01:03:13.933Z","updated_at":"2025-04-06T11:07:53.589Z","avatar_url":"https://github.com/dalmia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sinusoidal Representation Networks (SIREN)\n\nUnofficial PyTorch implementation of Sinusodial Representation networks (SIREN) from the paper [Implicit Neural Representations with Periodic Activation Functions](https://arxiv.org/abs/2006.09661). This repository is a PyTorch port of [this](https://github.com/titu1994/tf_SIREN) excellent TF 2.0 implementation of the same.\n\nIf you are using this codebase in your research, please use the following citation:\n```\n@software{aman_dalmia_2020_3902941,\n  author       = {Aman Dalmia},\n  title        = {dalmia/siren},\n  month        = jun,\n  year         = 2020,\n  publisher    = {Zenodo},\n  version      = {v1.1},\n  doi          = {10.5281/zenodo.3902941},\n  url          = {https://doi.org/10.5281/zenodo.3902941}\n}\n```\n\n# Setup\n- Install using pip\n```\n$ pip install siren-torch\n```\n\n# Usage\n\n## Sine activation\nYou can use the `Sine` activation as any other activation\n```python\nfrom siren import Sine\n\nx = torch.rand(10)\ny = Sine(w0=1)(x)\n```\n\n## Initialization\nThe authors in the paper propose a principled way of intializing the layers for the SIREN model. The initialization function\ncan be used as any other initialization present in `torch.nn.init`.\n\n```python\nfrom siren.init import siren_uniform_\n\nw = torch.empty(3, 5)\nsiren_uniform_(w, mode='fan_in', c=6)\n```\n\n## SIREN model\nThe SIREN model used in the paper, with sine activation and custom initialization, can directly be created as follows.\n\n```python\nfrom siren import SIREN\n\n# defining the model\nlayers = [256, 256, 256, 256, 256]\nin_features = 2\nout_features = 3\ninitializer = 'siren'\nw0 = 1.0\nw0_initial = 30.0\nc = 6\nmodel = SIREN(\n    layers, in_features, out_features, w0, w0_initial,\n    initializer=initializer, c=c)\n\n# defining the input\nx = torch.rand(10, 2)\n\n# forward pass\ny = model(x)\n```\n\n# Results on Image Inpainting task\nA partial implementation of the image inpainting task is available as the `train_inpainting_siren.py` and `eval_inpainting_siren.py` scripts.\n\nTo run training:\n```bash\n$ python scripts/train_inpainting_siren.py\n```\n\nTo run evaluation:\n```bash\n$ python scripts/eval_inpainting_siren.py\n```\n\nWeight files are made available in the repository under the `checkpoints` directory. It generates the following output after 5000 epochs of training with batch size 8192 while using only 10% of the available pixels in the image during training phase.\n\n\u003cimg src=\"https://github.com/dalmia/siren/blob/master/images/celtic_spiral_knot.jpg?raw=true\" height=100% width=100%\u003e\n\n# Tests\nTests are written using `unittest`. You can run any script under the `tests` folder.\n\n# Contributing\nAs mentioned at the beginning, this codebase is a PyTorch port of [this](https://github.com/titu1994/tf_SIREN). So, I might have missed a few details mentioned in the original paper. Assuming that the implemention in the linked repo is correct, one can safely trust this implementation as well. The only major difference from the reference repo is that it has `w0` as part of the initialization as well. I did not see that in the paper and hence, didn't include it here. I have not deeply read the paper and this is simply to serve as a starting point for anyone looking for the implementation. Please feel free to make a PR or create an issue if you find a bug or you want to contribute to improve any other aspect of the codebase.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalmia%2Fsiren","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalmia%2Fsiren","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalmia%2Fsiren/lists"}