提交 746b8dd9 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

commented version of scan; I took out the updates ( which could have resulted in many issues)

上级 6ff2fca5
差异被折叠。
...@@ -95,7 +95,7 @@ class T_Scan(unittest.TestCase): ...@@ -95,7 +95,7 @@ class T_Scan(unittest.TestCase):
# non sequence arguments # non sequence arguments
def test_1(self): def test_1(self):
def f_pow2(x_tm1): def f_pow2(x_tm1):
return (2*x_tm1, {}) return 2*x_tm1
s = theano.tensor.dscalar() s = theano.tensor.dscalar()
n_steps = theano.tensor.dscalar() n_steps = theano.tensor.dscalar()
...@@ -109,7 +109,7 @@ class T_Scan(unittest.TestCase): ...@@ -109,7 +109,7 @@ class T_Scan(unittest.TestCase):
# vectors, weights are scalars # vectors, weights are scalars
def test_2(self): def test_2(self):
def f_rnn(u_t,x_tm1,W_in, W): def f_rnn(u_t,x_tm1,W_in, W):
return (u_t*W_in+x_tm1*W, {}) return u_t*W_in+x_tm1*W
u = theano.tensor.dvector() u = theano.tensor.dvector()
x0 = theano.tensor.dscalar() x0 = theano.tensor.dscalar()
...@@ -134,7 +134,7 @@ class T_Scan(unittest.TestCase): ...@@ -134,7 +134,7 @@ class T_Scan(unittest.TestCase):
W = theano.shared(1., name ='w') W = theano.shared(1., name ='w')
def f_rnn_shared(u_t,x_tm1): def f_rnn_shared(u_t,x_tm1):
return (u_t*W_in+x_tm1*W, {}) return u_t*W_in+x_tm1*W
Y = theano.sandbox.scan.scan(f_rnn_shared, u,x0,[]) Y = theano.sandbox.scan.scan(f_rnn_shared, u,x0,[])
...@@ -177,7 +177,7 @@ class T_Scan(unittest.TestCase): ...@@ -177,7 +177,7 @@ class T_Scan(unittest.TestCase):
assert( compareArrays(x,v_x)) assert( compareArrays(x,v_x))
assert( compareArrays(y,v_y)) assert( compareArrays(y,v_y))
'''
# basic ESN using updates # basic ESN using updates
def test_5(self): def test_5(self):
W_in = theano.shared(numpy.array([1.,1.]), name='win') W_in = theano.shared(numpy.array([1.,1.]), name='win')
...@@ -225,7 +225,7 @@ class T_Scan(unittest.TestCase): ...@@ -225,7 +225,7 @@ class T_Scan(unittest.TestCase):
out = f6(v_u, v_y0) out = f6(v_u, v_y0)
assert( compareArrays(out, v_out)) assert( compareArrays(out, v_out))
'''
# simple rnn, one input, one state, weights for each; input/state are # simple rnn, one input, one state, weights for each; input/state are
# vectors, weights are scalars; using shared variables and past # vectors, weights are scalars; using shared variables and past
# taps (sequences and outputs) # taps (sequences and outputs)
...@@ -237,7 +237,7 @@ class T_Scan(unittest.TestCase): ...@@ -237,7 +237,7 @@ class T_Scan(unittest.TestCase):
W = theano.shared(1., name ='w') W = theano.shared(1., name ='w')
def f_rnn_shared(u_tm2, x_tm1, x_tm2): def f_rnn_shared(u_tm2, x_tm1, x_tm2):
return (u_tm2*W_in+x_tm1*W+x_tm2, {}) return u_tm2*W_in+x_tm1*W+x_tm2
Y = theano.sandbox.scan.scan(f_rnn_shared, u,x0, [], \ Y = theano.sandbox.scan.scan(f_rnn_shared, u,x0, [], \
sequences_taps = {0:[-2]}, outputs_taps = {0:[-1,-2]}) sequences_taps = {0:[-2]}, outputs_taps = {0:[-1,-2]})
...@@ -259,7 +259,7 @@ class T_Scan(unittest.TestCase): ...@@ -259,7 +259,7 @@ class T_Scan(unittest.TestCase):
W = theano.shared(1., name ='w') W = theano.shared(1., name ='w')
def f_rnn_shared(u_tm2,u_tp2, x_tm1, x_tm2): def f_rnn_shared(u_tm2,u_tp2, x_tm1, x_tm2):
return ((u_tm2+u_tp2)*W_in+x_tm1*W+x_tm2, {}) return (u_tm2+u_tp2)*W_in+x_tm1*W+x_tm2
Y = theano.sandbox.scan.scan(f_rnn_shared, u,x0, [], \ Y = theano.sandbox.scan.scan(f_rnn_shared, u,x0, [], \
sequences_taps = {0:[-2,2]}, outputs_taps = {0:[-1,-2]}) sequences_taps = {0:[-2,2]}, outputs_taps = {0:[-1,-2]})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论