提交 87398e77 authored 作者: Tanjay94's avatar Tanjay94

Moved power function in the right folder.

上级 02cafd6b
...@@ -1202,7 +1202,3 @@ class EigvalshGrad(Op): ...@@ -1202,7 +1202,3 @@ class EigvalshGrad(Op):
def eigvalsh(a, b, lower=True): def eigvalsh(a, b, lower=True):
return Eigvalsh(lower)(a, b) return Eigvalsh(lower)(a, b)
def power(x,y):
return x**y
...@@ -601,23 +601,3 @@ def test_eigvalsh_grad(): ...@@ -601,23 +601,3 @@ def test_eigvalsh_grad():
b = 10 * numpy.eye(5, 5) + rng.randn(5, 5) b = 10 * numpy.eye(5, 5) + rng.randn(5, 5)
tensor.verify_grad(lambda a, b: eigvalsh(a, b).dot([1, 2, 3, 4, 5]), tensor.verify_grad(lambda a, b: eigvalsh(a, b).dot([1, 2, 3, 4, 5]),
[a, b], rng=numpy.random) [a, b], rng=numpy.random)
class T_Power():
def test_numpy_compare(self):
rng = numpy.random.RandomState(utt.fetch_seed())
A = tensor.matrix("A", dtype=theano.config.floatX)
Q = power(A, 3)
fn = function([A], [Q])
a = rng.rand(4, 4).astype(theano.config.floatX)
n_p = numpy.power(a, 3)
t_p = fn(a)
assert numpy.allclose(n_p, t_p)
def test_multiple_power(self):
x = tensor.matrix()
y = [1, 2, 3]
z = power(x,y)
f = function([x], z)
assert allclose(f([1, 2, 3]), [1, 4, 27])
...@@ -5021,3 +5021,7 @@ def ptp(a, axis=None): ...@@ -5021,3 +5021,7 @@ def ptp(a, axis=None):
out = max(a, axis) - min(a, axis) out = max(a, axis) - min(a, axis)
return out return out
def power(x,y):
return x**y
...@@ -6881,6 +6881,25 @@ if __name__ == '__main__': ...@@ -6881,6 +6881,25 @@ if __name__ == '__main__':
t.test_infer_shape() t.test_infer_shape()
class T_Power():
def test_numpy_compare(self):
rng = numpy.random.RandomState(utt.fetch_seed())
A = tensor.matrix("A", dtype=theano.config.floatX)
Q = power(A, 3)
fn = function([A], [Q])
a = rng.rand(4, 4).astype(theano.config.floatX)
n_p = numpy.power(a, 3)
t_p = fn(a)
assert numpy.allclose(n_p, t_p)
def test_multiple_power(self):
x = tensor.matrix()
y = [1, 2, 3]
z = power(x,y)
f = function([x], z)
assert allclose(f([1, 2, 3]), [1, 4, 27])
""" """
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论