theano scan 实例

来源:互联网 发布:python 内存 结构 编辑:程序博客网 时间:2024/05/21 06:12
import theanoimport numpy as npones1 = theano.shared(np.float32([[1,2,3],[4,5,6],[7,8,9]]))ones2 = theano.shared(np.float32([[9,8,7],[6,5,4],[3,2,1]]))print(ones1.eval())outputs, updates = theano.scan(lambda ones1,ones2 : ones1 + 1,                               sequences = [ones1,ones2])print(outputs.eval())outputs, updates = theano.scan(lambda ones1,ones2 : ones2 + 1,                               sequences = [ones1,ones2])print(outputs.eval())

结果:

[[ 1. 2. 3.]
[ 4. 5. 6.]
[ 7. 8. 9.]]

[[ 2. 3. 4.]
[ 5. 6. 7.]
[ 8. 9. 10.]]

[[ 10. 9. 8.]
[ 7. 6. 5.]
[ 4. 3. 2.]]

0 0
原创粉丝点击