提交 ec195403 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Add method updates() and member state_updates to MRG_RandomStreams

Make easier the transition to MRG_RandomStreams from code using RandomStreams or SharedRandomStreams.
上级 f7e6acbd
......@@ -556,6 +556,13 @@ class GPU_mrg_uniform(mrg_uniform_base):
class MRG_RandomStreams(object):
"""Module component with similar interface to numpy.random (numpy.random.RandomState)"""
state_updates = []
"""A list of pairs of the form (input_r, output_r), representing the
update rules of all the random states generated by this RandomStreams"""
def updates(self):
return list(self.state_updates)
def __init__(self, seed=12345, use_cuda=None):
"""
:type seed: int or list of 6 int.
......@@ -627,6 +634,7 @@ class MRG_RandomStreams(object):
def pretty_return(self, node_rstate, new_rstate, sample):
sample.rstate = node_rstate
sample.update = (node_rstate, new_rstate)
self.state_updates.append((node_rstate, new_rstate))
node_rstate.default_update = new_rstate
return sample
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论