两点说明:
- theano的语法习惯是先定义类型,最后赋值的做法
- theano中scan函数是用来做循环使用的。
最简单的其形式如下:
theano.scan(fn ,squences ,outputs_info ,non_sequences)
其中,fn是循环函数,squences ,outputs_info ,non_sequences都是fn的参数,简明解释如下:
fn:循环函数
squence:以时序方式给出的参数,形如[s1,s2,...st-1,st]
outputs_info:当t=0时表示输出的初始化值,在时间步t时相当于fn的t-1时刻的output值
non_sequences:相当于是静态变量,在循环过程中不变的值
fn通常以lambda表达式方式给出,fn参数列表中参数给出的顺序和scan接收参数顺序有关,因此要将其顺序对应起来。
scan中接收参数的顺序在代码中有说明,这里直接放出scan函数中的说明:
The order of the sequences is the same as the one in the list
`sequences` given to scan. The order of the outputs is the same