rng = RandomStreams()
res, updates = th.map(lambda x: rng.binomial(),
T.arange(10))
final_res, final_updates = th.scan(lambda x: res,
sequences=T.arange(10))
想象一下,我想要实现一些类似的东西。问题是map
使用RNG,所以它有自己的非空白更新来更新RNG状态。如何强制updates
在scan
内执行?
答案 0 :(得分:0)
根据scan
源代码文档:
The function is expected to return two things. One is a list of
outputs ordered in the same order as ``outputs_info``, with the
difference that there should be only one output variable per
output initial state (even if no tap value is used). Secondly
`fn` should return an update dictionary (that tells how to
update any shared variable after each iteration step). The
dictionary can optionally be given as a list of tuples. There is
no constraint on the order of these two list, ``fn`` can return
either ``(outputs_list, update_dictionary)`` or
``(update_dictionary, outputs_list)`` or just one of the two (in
case the other is empty).