1.安装
该包是一个综合了FFT,scat等变换变换的工具包
要求:
python version >=3.6
torch version>=0.4
scipy version>=0.13
安装torch建议使用anaconda自带的conda安装
conda install pytorch torchvision -c pytorch
git clone https://github.com/kymatio/kymatio#下载该源
cd kymatio
pip install -r requirements.txt#cpu版本
pip install -r requirements_optional.txt#GPU版本
python setup.py install
2.验证安装是否成功
import torch
from kymatio import Scattering2D
scattering = Scattering2D(J=2, shape=(32, 32))
x = torch.randn(1, 1, 32, 32)
Sx = scattering(x)
如果无输出错误,那么安装成功,如果出现:
RuntimeError: fft: ATen not compiled with MKL support
错误,解决办法:使用conda 重新安装pytorch
使用GPU情况:
scattering.cuda()#GPU格式scattering
x_gpu = x.cuda()#转为GPU格式
Sx_gpu = scattering(x)#使用GPU scattering计算散射系数
Sx_gpu = Sx_gpu.cpu()#转为cpu格式
print(torch.norm(Sx_gpu-Sx))
scattering.cpu()
Kymatio库地址
欢迎交流?