zh217/torch-dct
zh217/torch-dct has 645 GitHub stars and 73 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-19 14:32 UTC. Last push 2022-11-06.
实测星标增长
- 24小时
- 0
- 7天
- 正在收集历史
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
关于
DCT (discrete cosine transform) functions for pytorch
机器学习README.md
原文DCT (Discrete Cosine Transform) for pytorch
This library implements DCT in terms of the built-in FFT operations in pytorch so that back propagation works through it, on both CPU and GPU. For more information on DCT and the algorithms used here, see Wikipedia and the paper by J. Makhoul. This StackExchange article might also be helpful.
The following are currently implemented:
- 1-D DCT-I and its inverse (which is a scaled DCT-I)
- 1-D DCT-II and its inverse (which is a scaled DCT-III)
- 2-D DCT-II and its inverse (which is a scaled DCT-III)
- 3-D DCT-II and its inverse (which is a scaled DCT-III)
Install
pip install torch-dct
Requires torch>=0.4.1 (lower versions are probably OK but I haven't tested them).
You can run test by getting the source and run pytest. To run the test you also
need scipy installed.
Usage
import torch
import torch_dct as dct
x = torch.randn(200)
X = dct.dct(x) # DCT-II done through the last dimension
y = dct.idct(X) # scaled DCT-III done through the last dimension
assert (torch.abs(x - y)).sum() < 1e-10 # x == y within numerical tolerance
dct.dct1 and dct.idct1 are for DCT-I and its inverse. The usage is the same.
Just replace dct and idct by dct_2d, dct_3d, idct_2d, idct_3d, etc
to get the multidimensional versions.