提交 f4edcc59 authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #3186 from nouiz/mixed

Mixed
...@@ -63,6 +63,11 @@ To get an error if Theano can not use cuDNN, use this Theano flag: ...@@ -63,6 +63,11 @@ To get an error if Theano can not use cuDNN, use this Theano flag:
There is a problem we do not understand yet when cudnn paths are There is a problem we do not understand yet when cudnn paths are
used with symbolic links. So avoid using that. used with symbolic links. So avoid using that.
.. note::
cudnn.so* must be readable and executable by everybody.
cudnn.h must be readable by everybody.
Functions Functions
========= =========
......
...@@ -465,11 +465,19 @@ There are :ref:`other distributions implemented <libdoc_tensor_raw_random>`. ...@@ -465,11 +465,19 @@ There are :ref:`other distributions implemented <libdoc_tensor_raw_random>`.
Other Implementations Other Implementations
--------------------- ---------------------
There is 2 other implementations based on :class:`CURAND There is 2 other implementations based on :ref:`MRG31k3p
<theano.sandbox.cuda.rng_curand>` and :ref:`MRG31k3p <libdoc_rng_mrg>` and :class:`CURAND <theano.sandbox.cuda.rng_curand>`.
<libdoc_rng_mrg>`. The RandomStream only work on the CPU, MRG31k3p The RandomStream only work on the CPU, MRG31k3p
work on the CPU and GPU. CURAND only work on the GPU. work on the CPU and GPU. CURAND only work on the GPU.
.. note::
To use you the MRG version easily, you can just change the import to:
.. code-block:: python
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
.. _logistic_regression: .. _logistic_regression:
......
...@@ -3539,6 +3539,9 @@ class GpuAllocEmpty(GpuOp): ...@@ -3539,6 +3539,9 @@ class GpuAllocEmpty(GpuOp):
def make_node(self, *shape): def make_node(self, *shape):
shape, output = self.validate_shape(shape) shape, output = self.validate_shape(shape)
output.tag.values_eq_approx = tensor.type.values_eq_approx_always_true output.tag.values_eq_approx = tensor.type.values_eq_approx_always_true
# The outut can contain nan/inf. output.type is a new
# instance, so we can do this only for that variable.
output.type.filter_checks_isfinite = False
return Apply(self, shape, [output]) return Apply(self, shape, [output])
def perform(self, node, inputs, out_): def perform(self, node, inputs, out_):
......
...@@ -73,8 +73,20 @@ def alpha_merge(cls, alpha_in, beta_in, nd): ...@@ -73,8 +73,20 @@ def alpha_merge(cls, alpha_in, beta_in, nd):
if lr is None or targ is None: if lr is None or targ is None:
return None return None
inputs = list(targ.inputs) inputs = list(targ.inputs)
inputs[alpha_in] = lr * targ.inputs[alpha_in] try:
inputs[beta_in] = lr * targ.inputs[beta_in] c = get_scalar_constant_value(lr)
if c == 0:
inputs[alpha_in] = lr
inputs[beta_in] = lr
elif c == 1:
inputs[alpha_in] = targ.inputs[alpha_in]
inputs[beta_in] = targ.inputs[beta_in]
else:
inputs[alpha_in] = lr * targ.inputs[alpha_in]
inputs[beta_in] = lr * targ.inputs[beta_in]
except NotScalarConstantError:
inputs[alpha_in] = lr * targ.inputs[alpha_in]
inputs[beta_in] = lr * targ.inputs[beta_in]
return maker(targ, *inputs) return maker(targ, *inputs)
return opt return opt
return wrapper return wrapper
......
...@@ -713,6 +713,8 @@ class GpuAllocEmpty(HideC, Alloc): ...@@ -713,6 +713,8 @@ class GpuAllocEmpty(HideC, Alloc):
sh, bcast = self.validate_shape(shape) sh, bcast = self.validate_shape(shape)
output = GpuArrayType(dtype=self.dtype, broadcastable=bcast)() output = GpuArrayType(dtype=self.dtype, broadcastable=bcast)()
output.tag.values_eq_approx = tensor.type.values_eq_approx_always_true output.tag.values_eq_approx = tensor.type.values_eq_approx_always_true
# The outut can contain nan/inf.
output.type.filter_checks_isfinite = False
return Apply(self, sh, [output]) return Apply(self, sh, [output])
def perform(self, node, inputs, out_): def perform(self, node, inputs, out_):
......
...@@ -75,8 +75,20 @@ def alpha_merge(cls, alpha_in, beta_in, nd): ...@@ -75,8 +75,20 @@ def alpha_merge(cls, alpha_in, beta_in, nd):
if lr is None or targ is None: if lr is None or targ is None:
return None return None
inputs = list(targ.inputs) inputs = list(targ.inputs)
inputs[alpha_in] = lr * targ.inputs[alpha_in] try:
inputs[beta_in] = lr * targ.inputs[beta_in] c = get_scalar_constant_value(lr)
if c == 0:
inputs[alpha_in] = lr
inputs[beta_in] = lr
elif c == 1:
inputs[alpha_in] = targ.inputs[alpha_in]
inputs[beta_in] = targ.inputs[beta_in]
else:
inputs[alpha_in] = lr * targ.inputs[alpha_in]
inputs[beta_in] = lr * targ.inputs[beta_in]
except NotScalarConstantError:
inputs[alpha_in] = lr * targ.inputs[alpha_in]
inputs[beta_in] = lr * targ.inputs[beta_in]
return maker(targ, *inputs) return maker(targ, *inputs)
return opt return opt
return wrapper return wrapper
......
...@@ -5709,6 +5709,9 @@ class AllocEmpty(gof.Op): ...@@ -5709,6 +5709,9 @@ class AllocEmpty(gof.Op):
def make_node(self, *shape): def make_node(self, *shape):
shape, output = self.validate_shape(shape) shape, output = self.validate_shape(shape)
output.tag.values_eq_approx = values_eq_approx_always_true output.tag.values_eq_approx = values_eq_approx_always_true
# The outut can contain nan/inf. output.type is a new
# instance, so we can do this only for that variable.
output.type.filter_checks_isfinite = False
return Apply(self, shape, [output]) return Apply(self, shape, [output])
def perform(self, node, inputs, out_): def perform(self, node, inputs, out_):
......
...@@ -1009,6 +1009,8 @@ def inc_subtensor(x, y, inplace=False, set_instead_of_inc=False, ...@@ -1009,6 +1009,8 @@ def inc_subtensor(x, y, inplace=False, set_instead_of_inc=False,
:param x: the symbolic result of a Subtensor operation. :param x: the symbolic result of a Subtensor operation.
:param y: the amount by which to increment ths subtensor in question :param y: the amount by which to increment ths subtensor in question
:param inplace: Don't use. Theano will do it when possible.
:param set_instead_of_inc: If True, do a set_subtensor instead.
:param tolerate_inplace_aliasing: allow x and y to be views of a single :param tolerate_inplace_aliasing: allow x and y to be views of a single
underlying array even while working inplace. For correct results, underlying array even while working inplace. For correct results,
x and y must not be overlapping views; if they overlap, the result x and y must not be overlapping views; if they overlap, the result
......
...@@ -4898,13 +4898,9 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin): ...@@ -4898,13 +4898,9 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin):
topo_ = [node for node in topo if not isinstance(node.op, topo_ = [node for node in topo if not isinstance(node.op,
self.ignore_topo)] self.ignore_topo)]
assert len(topo_) == 1, topo_ assert len(topo_) == 1, topo_
assert type(topo_[0].op) is self.op
return f return f
def eval_output_and_check(self, t):
f = self.function([], t)
tval = f()
return tval
def test_reshape(self): def test_reshape(self):
a = dvector() a = dvector()
b = dmatrix() b = dmatrix()
...@@ -5020,6 +5016,11 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin): ...@@ -5020,6 +5016,11 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin):
self.assertRaises(ValueError, f, a_val, [7, 5]) self.assertRaises(ValueError, f, a_val, [7, 5])
self.assertRaises(ValueError, f, a_val, [-1, -1]) self.assertRaises(ValueError, f, a_val, [-1, -1])
def test_0(self):
x = fvector('x')
f = self.function([x], x.reshape((0, 100)))
assert f(numpy.ndarray((0,), dtype='float32')).shape == (0, 100)
def test_make_column_matrix_broadcastable(): def test_make_column_matrix_broadcastable():
# The goal of the operation made by `b` is to ensure the second dimension # The goal of the operation made by `b` is to ensure the second dimension
......
...@@ -34,7 +34,7 @@ class test_casting(unittest.TestCase): ...@@ -34,7 +34,7 @@ class test_casting(unittest.TestCase):
for type1 in ['uint8', 'uint16', 'uint32', 'uint64', for type1 in ['uint8', 'uint16', 'uint32', 'uint64',
'int8', 'int16', 'int32', 'int64', 'float32', 'float64']: 'int8', 'int16', 'int32', 'int64', 'float32', 'float64']:
x = TensorType(dtype=type1, x = TensorType(dtype=type1,
broadcastable=(False, )).make_variable() broadcastable=(False, ))()
for type2, converter in zip(['int8', 'int16', 'int32', 'int64', for type2, converter in zip(['int8', 'int16', 'int32', 'int64',
'float32', 'float64'], 'float32', 'float64'],
[_convert_to_int8, _convert_to_int16, [_convert_to_int8, _convert_to_int16,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论