{"id":34057617,"url":"https://github.com/jwr1995/dc1d","last_synced_at":"2026-03-27T04:31:54.115Z","repository":{"id":62126848,"uuid":"524094757","full_name":"jwr1995/dc1d","owner":"jwr1995","description":"A 1D implementation of a deformable convolutional layer in PyTorch with a few tricks.","archived":false,"fork":false,"pushed_at":"2023-08-17T16:52:00.000Z","size":100,"stargazers_count":46,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-23T10:16:42.008Z","etag":null,"topics":["convolutional-layers","convolutional-neural-networks","deep-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/jwr1995.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}},"created_at":"2022-08-12T13:17:19.000Z","updated_at":"2025-11-16T18:07:40.000Z","dependencies_parsed_at":"2023-01-23T18:15:41.777Z","dependency_job_id":null,"html_url":"https://github.com/jwr1995/dc1d","commit_stats":{"total_commits":39,"total_committers":5,"mean_commits":7.8,"dds":"0.28205128205128205","last_synced_commit":"6ca2e01d1dff681830a71a0bb1e4e75e3a5f9396"},"previous_names":["jwr1995/deformconv1d"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jwr1995/dc1d","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwr1995%2Fdc1d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwr1995%2Fdc1d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwr1995%2Fdc1d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwr1995%2Fdc1d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwr1995","download_url":"https://codeload.github.com/jwr1995/dc1d/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwr1995%2Fdc1d/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31019443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T03:51:26.850Z","status":"ssl_error","status_checked_at":"2026-03-27T03:51:09.693Z","response_time":164,"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":["convolutional-layers","convolutional-neural-networks","deep-learning","pytorch"],"created_at":"2025-12-14T03:43:58.959Z","updated_at":"2026-03-27T04:31:54.107Z","avatar_url":"https://github.com/jwr1995.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dc1d (DeformConv1d)\nA 1D implementation of a deformable convolutional layer implemented in pure Python in PyTorch. The code style is designed to imitate similar classes in PyTorch such as ```torch.nn.Conv1D``` and ```torchvision.ops.DeformConv2D```.\n\nThe motivation for creating this toolkit is as of 19/10/2022 there is no native 1D implementation of deformable convolution in the PyTorch library and no alternate library which is simple to install (requiring only a basic PyTorch installation with no additional compilation of c++ or cuda libraries). The implementation here is written entirely in Python and makes use of ```torch.autograd``` for backpropagation.\n\n# Requirements\nYou must install PyTorch. Follow the details on the website to install properly: https://pytorch.org/get-started/locally/.\n\nThis package was most thoroughly tested on PyTorch 1.12.1 running CUDA 11.6 on Windows with Python version 3.8. It has also been tested on Ubuntu, Zorin OS and CentOS all running Python 3.8.\n\n# Installation\nPlease use the following ```pip``` command to install for now.\n\nMost thoroughly tested version (only \"reflect\" padding mode is implemented on this version, please do not try to use any other):\n```\npip install dc1d==0.0.4\n```\nAlternatively to install the latest version do\n```\npip install dc1d\n```\nThe current version on this branch has not been tested for numerical accuracy but probably works fine. Gradient computation has been tested and seems okay.\nTo download direct from source do\n```\ngit clone https://github.com/jwr1995/dc1d.git\ncd dc1d\npip install .\n```\n\n\n# Usage\n## Example of how to use the deformable convolutional layer ```DeformConv1d()``` with timing information.\n```DeformConv1d``` is the deformable convolution layer designed to imitate ```torch.nn.Conv1d```.\nNote: ```DeformConv1d``` does not compute the offset values used in its ```forward(...)``` call. These most be computed outside the layer.\n\n```\nimport time\nimport torch\nfrom torch import nn\n\n# Import layer\nfrom dc1d.nn import DeformConv1d\n\n# Hyperparameters\nbatch_size = 16\nin_channels = 512\nout_channels = 512\nkernel_size = 16\nstride = 1\npadding = \"valid\"\ndilation = 3\ngroups = 1\nbias = True\nlength = 128\n\n# Construct layer\nmodel = DeformConv1d(\n    in_channels = in_channels,\n    out_channels = out_channels,\n    kernel_size = kernel_size,\n    stride = stride,\n    padding = padding,\n    dilation = dilation,\n    groups = groups,\n    bias = True,\n)\n\n# Generate input sequence\nx = torch.rand(batch_size, in_channels, length,requires_grad=True)\nprint(x.shape)\n\n# Generate offsets by first computing the desired output length\noutput_length = x.shape[-1]-dilation*(kernel_size-1)\noffsets = nn.Parameter(torch.ones(batch_size, 1, output_length, kernel_size, requires_grad=True))\n\n# Process the input sequence and time it\nstart = time.time()\ny = model(x, offsets)\nend = time.time()\n\n# Print output shape and time taken\nprint(y.shape)\nprint(\"Deformable runtime =\",end-start)\n```\n---\nFor more detailed examples, the ```nn``` and ```ops``` modules have example usage scripts appended to the bottom of the file inside their ```if __name__ == \"__main__\":``` clauses. For example one could run \n```\npython dc1d/nn.py\n```\nto compare the runtime of our ```DeformConv1d``` layer against ```torch.nn.Conv1d```.\n\nA class called ```PackedConv1d``` also exists in ```dc1d.nn``` which computes the offsets using a depthwise-separable convolutional block as detailed in our paper below.\n\n# Papers\nPlease cite the following if you use this package\n```\n@INPROCEEDINGS{dtcn23,\n  author={Ravenscroft, William and Goetze, Stefan and Hain, Thomas},\n  booktitle={ICASSP 2023 - 2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)}, \n  title={Deformable Temporal Convolutional Networks for Monaural Noisy Reverberant Speech Separation}, \n  year={2023},\n  volume={},\n  number={},\n  pages={1-5},\n  doi={10.1109/ICASSP49357.2023.10095230}}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwr1995%2Fdc1d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwr1995%2Fdc1d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwr1995%2Fdc1d/lists"}