栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python 对图像进行傅里叶变换 fft2

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python 对图像进行傅里叶变换 fft2

==>> Wed Mar  9 11:11:56 2022 [Iter 1/8]   loss = 8833.374023
====>> Wed Mar  9 11:11:56 2022   Pass time: 0:00:17.003332
Traceback (most recent call last):
  File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 361, in 
    train(opt)
  File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 289, in train
    lap = -(cmul(fft2(grd_x), cconj(fft2(grd_x), inplace=False)) + cmul(fft2(grd_y), cconj(fft2(grd_y), inplace=False)))
  File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 138, in fft2
    return torch.fft.fft2(t, 2)
AttributeError: 'builtin_function_or_method' object has no attribute 'fft2'

Process finished with exit code 1

原来的代码在fft2报错,搜索之后搞成np数组的函数,然后错误换了,定位到了‘_pocketfft.py’这个子函数,从函数的解释看到了np.fft.fft2的使用方法,改正后这行就不报错啦

这个是函数的定义例子

 Examples
    --------
    >>> a = np.mgrid[:5, :5][0]
    >>> np.fft.fft2(a)
    array([[ 50.  +0.j        ,   0.  +0.j        ,   0.  +0.j        , # may vary
              0.  +0.j        ,   0.  +0.j        ],
           [-12.5+17.20477401j,   0.  +0.j        ,   0.  +0.j        ,
              0.  +0.j        ,   0.  +0.j        ],
           [-12.5 +4.0614962j ,   0.  +0.j        ,   0.  +0.j        ,
              0.  +0.j        ,   0.  +0.j        ],
           [-12.5 -4.0614962j ,   0.  +0.j        ,   0.  +0.j        ,
              0.  +0.j        ,   0.  +0.j        ],
           [-12.5-17.20477401j,   0.  +0.j        ,   0.  +0.j        ,
              0.  +0.j        ,   0.  +0.j        ]])

    """

我原来定义的代码

def fft2(t):
    return np.fft.fft2(t, 2)


def ifft2(t):
    return np.fft.ifft2(t, 2)

修改后本行不再报错的代码

def fft2(t):
    return np.fft.fft2(t)


def ifft2(t):
    return np.fft.ifft2(t)

哈哈哈哈哈,有那么一丢丢小开心,新错误来了,继续加油埋头苦干呐

====>> Thu Mar 10 17:06:33 2022   Pass time: 0:00:16.794601
Traceback (most recent call last):
  File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 361, in 
    train(opt)
  File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 289, in train
    lap = -(cmul(fft2(grd_x), cconj(fft2(grd_x), inplace=False)) + cmul(fft2(grd_y), cconj(fft2(grd_y), inplace=False)))
  File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 132, in cconj
    c = t.clone() if not inplace else t
AttributeError: 'numpy.ndarray' object has no attribute 'clone'

Process finished with exit code 1

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/757228.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号