{"id":19156237,"url":"https://github.com/kyegomez/ct","last_synced_at":"2025-08-16T12:30:15.380Z","repository":{"id":198904973,"uuid":"701789641","full_name":"kyegomez/CT","owner":"kyegomez","description":"Implementation of the attention and transformer from \"Building Blocks for a Complex-Valued Transformer Architecture\"","archived":false,"fork":false,"pushed_at":"2024-03-11T02:31:36.000Z","size":2266,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T23:17:49.734Z","etag":null,"topics":["artificial-intelligence","attention","attention-is-all-you-need","attention-mechanism","complex-numbers","complex-signals","dotproduct","fourier-transform"],"latest_commit_sha":null,"homepage":"https://discord.gg/qUtxnK2NMf","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/kyegomez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["kyegomez"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-10-07T15:05:33.000Z","updated_at":"2025-01-15T03:14:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"cab6e5c0-9d7e-40d5-834c-34a81a23753f","html_url":"https://github.com/kyegomez/CT","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"43d1afff43ded2e14661a6c91d64b73cfd7a86e9"},"previous_names":["kyegomez/ct"],"tags_count":0,"template":false,"template_full_name":"kyegomez/Python-Package-Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FCT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FCT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FCT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FCT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyegomez","download_url":"https://codeload.github.com/kyegomez/CT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252835959,"owners_count":21811630,"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":["artificial-intelligence","attention","attention-is-all-you-need","attention-mechanism","complex-numbers","complex-signals","dotproduct","fourier-transform"],"created_at":"2024-11-09T08:33:43.244Z","updated_at":"2025-05-07T07:41:12.429Z","avatar_url":"https://github.com/kyegomez.png","language":"Python","funding_links":["https://github.com/sponsors/kyegomez"],"categories":[],"sub_categories":[],"readme":"[![Multi-Modality](agorabanner.png)](https://discord.gg/qUtxnK2NMf)\n\n# Complex Transformer (WIP)\nThe open source implementation of the attention and transformer from \"Building Blocks for a Complex-Valued Transformer Architecture\" where they propose an an attention mechanism for complex valued signals or images such as MRI and remote sensing.\n\nThey present:\n- complex valued scaled dot product attention\n- complex valued layer normalization\n- results show improved robustness to overfitting while maintaing performance wbhen compared to real valued transformer\n\n## Install\n`pip install complex-attn`\n\n## Usage\n```python\nimport torch\nfrom ct.attention import ComplexAttention\n\n# # Usage example\ndim = 512\nheads = 8\nseq_len = 512\nbatch_size = 32\n\nq = torch.randn(batch_size, seq_len, dim) + 1j * torch.randn(\n    batch_size, seq_len, dim\n)\nk = torch.randn(batch_size, seq_len, dim) + 1j * torch.randn(\n    batch_size, seq_len, dim\n)\nv = torch.randn(batch_size, seq_len, dim) + 1j * torch.randn(\n    batch_size, seq_len, dim\n)\n\nattention_layer = ComplexAttention(\n    dim, \n    heads, \n    qk_norm=True,\n    dropout=0.1,\n)\nattn_output = attention_layer(q, k, v)\nprint(\"Attention Output Shape:\", attn_output.shape)\n\n```\n\n# Architecture\n- I use regular norm instead of complex norm for simplicity\n\n# License\nMIT\n\n# Citations\n```\n@article{2306.09827,\nAuthor = {Florian Eilers and Xiaoyi Jiang},\nTitle = {Building Blocks for a Complex-Valued Transformer Architecture},\nYear = {2023},\nEprint = {arXiv:2306.09827},\nDoi = {10.1109/ICASSP49357.2023.10095349},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyegomez%2Fct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyegomez%2Fct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyegomez%2Fct/lists"}