提交 5d6a2ac4 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Use get_value and set_value, not .value, in the library itself.

上级 875424b8
...@@ -4838,7 +4838,7 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None, abs_tol=None, rel_tol=No ...@@ -4838,7 +4838,7 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None, abs_tol=None, rel_tol=No
#get new random projection for next test #get new random projection for next test
if test_num < n_tests - 1: if test_num < n_tests - 1:
t_r.value = random_projection() t_r.set_value(random_projection(), borrow=True)
class GradientError(Exception): class GradientError(Exception):
......
...@@ -72,7 +72,8 @@ class RandomStreams(raw_random.RandomStreamsBase): ...@@ -72,7 +72,8 @@ class RandomStreams(raw_random.RandomStreamsBase):
seedgen = numpy.random.RandomState(seed) seedgen = numpy.random.RandomState(seed)
for old_r, new_r in self.state_updates: for old_r, new_r in self.state_updates:
old_r_seed = seedgen.randint(2**30) old_r_seed = seedgen.randint(2**30)
old_r.value = numpy.random.RandomState(int(old_r_seed)) old_r.set_value(numpy.random.RandomState(int(old_r_seed)),
borrow=True)
def __getitem__(self, item): def __getitem__(self, item):
"""Retrieve the numpy RandomState instance associated with a particular stream """Retrieve the numpy RandomState instance associated with a particular stream
...@@ -82,10 +83,10 @@ class RandomStreams(raw_random.RandomStreamsBase): ...@@ -82,10 +83,10 @@ class RandomStreams(raw_random.RandomStreamsBase):
:rtype: numpy RandomState (or None, before initialize) :rtype: numpy RandomState (or None, before initialize)
:note: This is kept for compatibility with `tensor.randomstreams.RandomStreams`. The :note: This is kept for compatibility with `tensor.randomstreams.RandomStreams`. The
simpler syntax ``item.rng.value`` is also valid. simpler syntax ``item.rng.get_value()`` is also valid.
""" """
return item.value return item.get_value()
def __setitem__(self, item, val): def __setitem__(self, item, val):
"""Set the numpy RandomState instance associated with a particular stream """Set the numpy RandomState instance associated with a particular stream
...@@ -98,10 +99,10 @@ class RandomStreams(raw_random.RandomStreamsBase): ...@@ -98,10 +99,10 @@ class RandomStreams(raw_random.RandomStreamsBase):
:rtype: None :rtype: None
:note: This is kept for compatibility with `tensor.randomstreams.RandomStreams`. The :note: This is kept for compatibility with `tensor.randomstreams.RandomStreams`. The
simpler syntax ``item.rng.value = val`` is also valid. simpler syntax ``item.rng.set_value(val)`` is also valid.
""" """
item.value = val item.set_value(val)
def gen(self, op, *args, **kwargs): def gen(self, op, *args, **kwargs):
"""Create a new random stream in this container. """Create a new random stream in this container.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论