{"id":26608067,"url":"https://github.com/zh217/torch-dct","last_synced_at":"2025-04-07T01:12:27.045Z","repository":{"id":41583676,"uuid":"149639960","full_name":"zh217/torch-dct","owner":"zh217","description":"DCT (discrete cosine transform) functions for pytorch","archived":false,"fork":false,"pushed_at":"2022-11-06T16:09:00.000Z","size":25,"stargazers_count":602,"open_issues_count":6,"forks_count":72,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T00:13:17.033Z","etag":null,"topics":["dct","dft","fct","fft","pytorch","torch"],"latest_commit_sha":null,"homepage":null,"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/zh217.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":"2018-09-20T16:38:15.000Z","updated_at":"2025-03-30T11:35:24.000Z","dependencies_parsed_at":"2022-07-15T16:37:37.836Z","dependency_job_id":null,"html_url":"https://github.com/zh217/torch-dct","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh217%2Ftorch-dct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh217%2Ftorch-dct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh217%2Ftorch-dct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh217%2Ftorch-dct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zh217","download_url":"https://codeload.github.com/zh217/torch-dct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247574089,"owners_count":20960496,"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":["dct","dft","fct","fft","pytorch","torch"],"created_at":"2025-03-23T23:31:57.887Z","updated_at":"2025-04-07T01:12:27.028Z","avatar_url":"https://github.com/zh217.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DCT (Discrete Cosine Transform) for pytorch\n\n[![Build Status](https://travis-ci.com/zh217/torch-dct.svg?branch=master)](https://travis-ci.com/zh217/torch-dct)\n[![codecov](https://codecov.io/gh/zh217/torch-dct/branch/master/graph/badge.svg)](https://codecov.io/gh/zh217/torch-dct)\n[![PyPI version](https://img.shields.io/pypi/v/torch-dct.svg)](https://pypi.python.org/pypi/torch-dct/)\n[![PyPI version](https://img.shields.io/pypi/pyversions/torch-dct.svg)](https://pypi.python.org/pypi/torch-dct/)\n[![PyPI status](https://img.shields.io/pypi/status/torch-dct.svg)](https://pypi.python.org/pypi/torch-dct/)\n[![GitHub license](https://img.shields.io/github/license/zh217/torch-dct.svg)](https://github.com/zh217/torch-dct/blob/master/LICENSE)\n\n\nThis library implements DCT in terms of the built-in FFT operations in pytorch so that\nback propagation works through it, on both CPU and GPU. For more information on\nDCT and the algorithms used here, see \n[Wikipedia](https://en.wikipedia.org/wiki/Discrete_cosine_transform) and the paper by\n[J. Makhoul](https://ieeexplore.ieee.org/document/1163351/). This\n[StackExchange article](https://dsp.stackexchange.com/questions/2807/fast-cosine-transform-via-fft)\nmight also be helpful.\n\nThe following are currently implemented:\n\n* 1-D DCT-I and its inverse (which is a scaled DCT-I)\n* 1-D DCT-II and its inverse (which is a scaled DCT-III)\n* 2-D DCT-II and its inverse (which is a scaled DCT-III)\n* 3-D DCT-II and its inverse (which is a scaled DCT-III)\n\n## Install\n\n```\npip install torch-dct\n```\n\nRequires `torch\u003e=0.4.1` (lower versions are probably OK but I haven't tested them).\n\nYou can run test by getting the source and run `pytest`. To run the test you also\nneed `scipy` installed.\n\n## Usage\n\n```python\nimport torch\nimport torch_dct as dct\n\nx = torch.randn(200)\nX = dct.dct(x)   # DCT-II done through the last dimension\ny = dct.idct(X)  # scaled DCT-III done through the last dimension\nassert (torch.abs(x - y)).sum() \u003c 1e-10  # x == y within numerical tolerance\n```\n\n`dct.dct1` and `dct.idct1` are for DCT-I and its inverse. The usage is the same.\n\nJust replace `dct` and `idct` by `dct_2d`, `dct_3d`, `idct_2d`, `idct_3d`, etc\nto get the multidimensional versions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzh217%2Ftorch-dct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzh217%2Ftorch-dct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzh217%2Ftorch-dct/lists"}