==>> 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, intrain(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, intrain(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



