提交 b5ddb5d0 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

removed unused allow_input_downcast

上级 0f0b300e
...@@ -18,20 +18,21 @@ def test001_jacobian_vector(): ...@@ -18,20 +18,21 @@ def test001_jacobian_vector():
# test when the jacobian is called with a tensor as wrt # test when the jacobian is called with a tensor as wrt
Jx = tensor.jacobian(y, x) Jx = tensor.jacobian(y, x)
f = theano.function([x], Jx, allow_input_downcast=True) f = theano.function([x], Jx)
vx = rng.uniform(size=(10,)).astype(theano.config.floatX) vx = rng.uniform(size=(10,)).astype(theano.config.floatX)
assert numpy.allclose(f(vx), numpy.eye(10) * 2) assert numpy.allclose(f(vx), numpy.eye(10) * 2)
# test when the jacobian is called with a tuple as wrt # test when the jacobian is called with a tuple as wrt
Jx = tensor.jacobian(y, (x,)) Jx = tensor.jacobian(y, (x,))
assert isinstance(Jx, tuple) assert isinstance(Jx, tuple)
f = theano.function([x], Jx[0], allow_input_downcast=True) f = theano.function([x], Jx[0])
vx = rng.uniform(size=(10,)).astype(theano.config.floatX) vx = rng.uniform(size=(10,)).astype(theano.config.floatX)
assert numpy.allclose(f(vx), numpy.eye(10) * 2) assert numpy.allclose(f(vx), numpy.eye(10) * 2)
# test when the jacobian is called with a list as wrt # test when the jacobian is called with a list as wrt
Jx = tensor.jacobian(y, [x]) Jx = tensor.jacobian(y, [x])
f = theano.function([x], Jx[0], allow_input_downcast=True) assert isinstance(Jx, list)
f = theano.function([x], Jx[0])
vx = rng.uniform(size=(10,)).astype(theano.config.floatX) vx = rng.uniform(size=(10,)).astype(theano.config.floatX)
assert numpy.allclose(f(vx), numpy.eye(10) * 2) assert numpy.allclose(f(vx), numpy.eye(10) * 2)
...@@ -39,7 +40,7 @@ def test001_jacobian_vector(): ...@@ -39,7 +40,7 @@ def test001_jacobian_vector():
z = tensor.vector() z = tensor.vector()
y = x * z y = x * z
Js = tensor.jacobian(y, [x, z]) Js = tensor.jacobian(y, [x, z])
f = theano.function([x, z], Js, allow_input_downcast=True) f = theano.function([x, z], Js)
vx = rng.uniform(size=(10,)).astype(theano.config.floatX) vx = rng.uniform(size=(10,)).astype(theano.config.floatX)
vz = rng.uniform(size=(10,)).astype(theano.config.floatX) vz = rng.uniform(size=(10,)).astype(theano.config.floatX)
vJs = f(vx, vz) vJs = f(vx, vz)
...@@ -62,20 +63,21 @@ def test002_jacobian_matrix(): ...@@ -62,20 +63,21 @@ def test002_jacobian_matrix():
# test when the jacobian is called with a tensor as wrt # test when the jacobian is called with a tensor as wrt
Jx = tensor.jacobian(y, x) Jx = tensor.jacobian(y, x)
f = theano.function([x], Jx, allow_input_downcast=True) f = theano.function([x], Jx)
vx = rng.uniform(size=(10, 10)).astype(theano.config.floatX) vx = rng.uniform(size=(10, 10)).astype(theano.config.floatX)
assert numpy.allclose(f(vx), ev) assert numpy.allclose(f(vx), ev)
# test when the jacobian is called with a tuple as wrt # test when the jacobian is called with a tuple as wrt
Jx = tensor.jacobian(y, (x,)) Jx = tensor.jacobian(y, (x,))
assert isinstance(Jx, tuple) assert isinstance(Jx, tuple)
f = theano.function([x], Jx[0], allow_input_downcast=True) f = theano.function([x], Jx[0])
vx = rng.uniform(size=(10, 10)).astype(theano.config.floatX) vx = rng.uniform(size=(10, 10)).astype(theano.config.floatX)
assert numpy.allclose(f(vx), ev) assert numpy.allclose(f(vx), ev)
# test when the jacobian is called with a list as wrt # test when the jacobian is called with a list as wrt
Jx = tensor.jacobian(y, [x]) Jx = tensor.jacobian(y, [x])
f = theano.function([x], Jx[0], allow_input_downcast=True) assert isinstance(Jx, list)
f = theano.function([x], Jx[0])
vx = rng.uniform(size=(10, 10)).astype(theano.config.floatX) vx = rng.uniform(size=(10, 10)).astype(theano.config.floatX)
assert numpy.allclose(f(vx), ev) assert numpy.allclose(f(vx), ev)
...@@ -83,7 +85,7 @@ def test002_jacobian_matrix(): ...@@ -83,7 +85,7 @@ def test002_jacobian_matrix():
z = tensor.matrix() z = tensor.matrix()
y = (x * z).sum(axis=1) y = (x * z).sum(axis=1)
Js = tensor.jacobian(y, [x, z]) Js = tensor.jacobian(y, [x, z])
f = theano.function([x, z], Js, allow_input_downcast=True) f = theano.function([x, z], Js)
vx = rng.uniform(size=(10, 10)).astype(theano.config.floatX) vx = rng.uniform(size=(10, 10)).astype(theano.config.floatX)
vz = rng.uniform(size=(10, 10)).astype(theano.config.floatX) vz = rng.uniform(size=(10, 10)).astype(theano.config.floatX)
vJs = f(vx, vz) vJs = f(vx, vz)
...@@ -103,20 +105,20 @@ def test003_jacobian_scalar(): ...@@ -103,20 +105,20 @@ def test003_jacobian_scalar():
# test when the jacobian is called with a tensor as wrt # test when the jacobian is called with a tensor as wrt
Jx = tensor.jacobian(y, x) Jx = tensor.jacobian(y, x)
f = theano.function([x], Jx, allow_input_downcast=True) f = theano.function([x], Jx)
vx = numpy.cast[theano.config.floatX](rng.uniform()) vx = numpy.cast[theano.config.floatX](rng.uniform())
assert numpy.allclose(f(vx), 2) assert numpy.allclose(f(vx), 2)
# test when the jacobian is called with a tuple as wrt # test when the jacobian is called with a tuple as wrt
Jx = tensor.jacobian(y, (x,)) Jx = tensor.jacobian(y, (x,))
assert isinstance(Jx, tuple) assert isinstance(Jx, tuple)
f = theano.function([x], Jx[0], allow_input_downcast=True) f = theano.function([x], Jx[0])
vx = numpy.cast[theano.config.floatX](rng.uniform()) vx = numpy.cast[theano.config.floatX](rng.uniform())
assert numpy.allclose(f(vx), 2) assert numpy.allclose(f(vx), 2)
# test when the jacobian is called with a list as wrt # test when the jacobian is called with a list as wrt
Jx = tensor.jacobian(y, [x]) Jx = tensor.jacobian(y, [x])
f = theano.function([x], Jx[0], allow_input_downcast=True) f = theano.function([x], Jx[0])
vx = numpy.cast[theano.config.floatX](rng.uniform()) vx = numpy.cast[theano.config.floatX](rng.uniform())
assert numpy.allclose(f(vx), 2) assert numpy.allclose(f(vx), 2)
...@@ -124,7 +126,7 @@ def test003_jacobian_scalar(): ...@@ -124,7 +126,7 @@ def test003_jacobian_scalar():
z = tensor.scalar() z = tensor.scalar()
y = x * z y = x * z
Jx = tensor.jacobian(y, [x, z]) Jx = tensor.jacobian(y, [x, z])
f = theano.function([x, z], Jx, allow_input_downcast=True) f = theano.function([x, z], Jx)
vx = numpy.cast[theano.config.floatX](rng.uniform()) vx = numpy.cast[theano.config.floatX](rng.uniform())
vz = numpy.cast[theano.config.floatX](rng.uniform()) vz = numpy.cast[theano.config.floatX](rng.uniform())
vJx = f(vx, vz) vJx = f(vx, vz)
...@@ -137,6 +139,6 @@ def test004_hessian(): ...@@ -137,6 +139,6 @@ def test004_hessian():
x = tensor.vector() x = tensor.vector()
y = tensor.sum(x ** 2) y = tensor.sum(x ** 2)
Hx = tensor.hessian(y, x) Hx = tensor.hessian(y, x)
f = theano.function([x], Hx, allow_input_downcast=True) f = theano.function([x], Hx)
vx = numpy.arange(10).astype(theano.config.floatX) vx = numpy.arange(10).astype(theano.config.floatX)
assert numpy.allclose(f(vx), numpy.eye(10) * 2) assert numpy.allclose(f(vx), numpy.eye(10) * 2)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论