2017-03-28 5 views
0
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 상태를 업데이트하기위한 비공개 업데이트가 있다는 것입니다. 어떻게 updatesscan 안에 강제로 실행할 수 있습니까? scan 소스 코드를 문서에 따르면theano 스캔 내에서 업데이트를 실행하십시오.

답변

0

: 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).