提交 2f4ac5a7 authored 作者: amrithasuresh's avatar amrithasuresh

Updated numpy as np

上级 374d9b28
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
import numpy import numpy as np
import math import math
from theano import gof, tensor from theano import gof, tensor
...@@ -98,7 +98,7 @@ class Fourier(gof.Op): ...@@ -98,7 +98,7 @@ class Fourier(gof.Op):
a = inputs[0] a = inputs[0]
n = inputs[1] n = inputs[1]
axis = inputs[2] axis = inputs[2]
output_storage[0][0] = numpy.fft.fft(a, n=int(n), axis=axis.item()) output_storage[0][0] = np.fft.fft(a, n=int(n), axis=axis.item())
def grad(self, inputs, cost_grad): def grad(self, inputs, cost_grad):
""" """
...@@ -128,7 +128,7 @@ class Fourier(gof.Op): ...@@ -128,7 +128,7 @@ class Fourier(gof.Op):
# tensor.set_subtensor(res[...,n::], 0, False, False), res) # tensor.set_subtensor(res[...,n::], 0, False, False), res)
# Instead we resort to that to account for truncation: # Instead we resort to that to account for truncation:
flip_shape = list(numpy.arange(0, a.ndim)[::-1]) flip_shape = list(np.arange(0, a.ndim)[::-1])
res = res.dimshuffle(flip_shape) res = res.dimshuffle(flip_shape)
res = tensor.switch(tensor.lt(n, tensor.shape(a)[axis]), res = tensor.switch(tensor.lt(n, tensor.shape(a)[axis]),
tensor.set_subtensor(res[n::, ], 0, False, False), tensor.set_subtensor(res[n::, ], 0, False, False),
...@@ -136,8 +136,8 @@ class Fourier(gof.Op): ...@@ -136,8 +136,8 @@ class Fourier(gof.Op):
res = res.dimshuffle(flip_shape) res = res.dimshuffle(flip_shape)
# insures that gradient shape conforms to input shape: # insures that gradient shape conforms to input shape:
out_shape = list(numpy.arange(0, axis)) + [a.ndim - 1] +\ out_shape = list(np.arange(0, axis)) + [a.ndim - 1] +\
list(numpy.arange(axis, a.ndim - 1)) list(np.arange(axis, a.ndim - 1))
res = res.dimshuffle(*out_shape) res = res.dimshuffle(*out_shape)
return [res, None, None] return [res, None, None]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论