Discussion:
[theano-users] recurrent layer - concatenate error
Madhavun Candadai
2017-04-29 17:46:46 UTC
Permalink
Hello,

I am trying to set up a recurrent neural network with multiple layers as
follows -

inputs = T.tensor3(name='inputs')
targets = T.dvector(name='targets')

# Input layer
l_in = lasagne.layers.InputLayer(([1,1,NUM_SENSORS]),inputs)

# recurrent layer
initRec1Weights =
lasagne.utils.create_param(np.eye(NUM_HIDDEN_UNITS)*4.+np.random.rand(NUM_HIDDEN_UN$

[NUM_HIDDEN_UNITS,NUM_HIDDEN_UNITS])
initRec2Weights =
lasagne.utils.create_param(np.eye(NUM_HIDDEN_UNITS)*4.+np.random.rand(NUM_HIDDEN_UN$

[NUM_HIDDEN_UNITS,NUM_HIDDEN_UNITS])
initRec3Weights =
lasagne.utils.create_param(np.eye(NUM_HIDDEN_UNITS)*4.+np.random.rand(NUM_HIDDEN_UN$

[NUM_HIDDEN_UNITS,NUM_HIDDEN_UNITS])

l_r1 = lasagne.layers.RecurrentLayer(l_in, NUM_HIDDEN_UNITS,
W_in_to_hid=lasagne.init.Uniform(range=2,std=None,mean=0.),
W_hid_to_hid=initRec1Weights,#lasagne.init.Constant(4.),
b=lasagne.init.Constant(0.),
nonlinearity=lasagne.nonlinearities.sigmoid,
gradient_steps=20) # number of steps for BPTT to unroll network

l_r2 = lasagne.layers.RecurrentLayer(l_r1, NUM_HIDDEN_UNITS,
W_in_to_hid=lasagne.init.Uniform(range=2,std=None,mean=0.),
W_hid_to_hid=initRec2Weights,#lasagne.init.Constant(4.),
b=lasagne.init.Constant(0.),
nonlinearity=lasagne.nonlinearities.sigmoid,
gradient_steps=BPTT_STEPS) # number of steps for BPTT to unroll network

l_r3 = lasagne.layers.RecurrentLayer(l_r2, NUM_HIDDEN_UNITS,
W_in_to_hid=lasagne.init.Uniform(range=2,std=None,mean=0.),
W_hid_to_hid=initRec3Weights,#lasagne.init.Constant(4.),
b=lasagne.init.Constant(0.),
nonlinearity=lasagne.nonlinearities.sigmoid,
gradient_steps=BPTT_STEPS) # number of steps for BPTT to unroll network

# output layer
l_out = lasagne.layers.DenseLayer(l_r3, NUM_OUTPUTS,
W=lasagne.init.Uniform(range=2,std=None,mean=0.),
nonlinearity=lasagne.nonlinearities.sigmoid)

but I am getting the following error -

Traceback (most recent call last):
File "categAgent.py", line 203, in <module>
gradient_steps=20) # number of steps for BPTT to unroll network
File
"/home/madvn/anaconda2/lib/python2.7/site-packages/lasagne/layers/recurrent.py",
line 552, in __init__
in_to_hid = DenseLayer(InputLayer((None,) + input_shape[2:]),
TypeError: can only concatenate tuple (not "list") to tuple

Please help. Thanks

- Madhavun
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jesse Livezey
2017-04-30 17:46:19 UTC
Permalink
I think you'll want to ask this question on the Lasagne forum
https://groups.google.com/forum/#!forum/lasagne-users
I don't think it is a problem with how you are using Theano.
Post by Madhavun Candadai
Hello,
I am trying to set up a recurrent neural network with multiple layers as
follows -
inputs = T.tensor3(name='inputs')
targets = T.dvector(name='targets')
# Input layer
l_in = lasagne.layers.InputLayer(([1,1,NUM_SENSORS]),inputs)
# recurrent layer
initRec1Weights =
lasagne.utils.create_param(np.eye(NUM_HIDDEN_UNITS)*4.+np.random.rand(NUM_HIDDEN_UN$
[NUM_HIDDEN_UNITS,NUM_HIDDEN_UNITS])
initRec2Weights =
lasagne.utils.create_param(np.eye(NUM_HIDDEN_UNITS)*4.+np.random.rand(NUM_HIDDEN_UN$
[NUM_HIDDEN_UNITS,NUM_HIDDEN_UNITS])
initRec3Weights =
lasagne.utils.create_param(np.eye(NUM_HIDDEN_UNITS)*4.+np.random.rand(NUM_HIDDEN_UN$
[NUM_HIDDEN_UNITS,NUM_HIDDEN_UNITS])
l_r1 = lasagne.layers.RecurrentLayer(l_in, NUM_HIDDEN_UNITS,
W_in_to_hid=lasagne.init.Uniform(range=2,std=None,mean=0.),
W_hid_to_hid=initRec1Weights,#lasagne.init.Constant(4.),
b=lasagne.init.Constant(0.),
nonlinearity=lasagne.nonlinearities.sigmoid,
gradient_steps=20) # number of steps for BPTT to unroll network
l_r2 = lasagne.layers.RecurrentLayer(l_r1, NUM_HIDDEN_UNITS,
W_in_to_hid=lasagne.init.Uniform(range=2,std=None,mean=0.),
W_hid_to_hid=initRec2Weights,#lasagne.init.Constant(4.),
b=lasagne.init.Constant(0.),
nonlinearity=lasagne.nonlinearities.sigmoid,
gradient_steps=BPTT_STEPS) # number of steps for BPTT to unroll network
l_r3 = lasagne.layers.RecurrentLayer(l_r2, NUM_HIDDEN_UNITS,
W_in_to_hid=lasagne.init.Uniform(range=2,std=None,mean=0.),
W_hid_to_hid=initRec3Weights,#lasagne.init.Constant(4.),
b=lasagne.init.Constant(0.),
nonlinearity=lasagne.nonlinearities.sigmoid,
gradient_steps=BPTT_STEPS) # number of steps for BPTT to unroll network
# output layer
l_out = lasagne.layers.DenseLayer(l_r3, NUM_OUTPUTS,
W=lasagne.init.Uniform(range=2,std=None,mean=0.),
nonlinearity=lasagne.nonlinearities.sigmoid)
but I am getting the following error -
File "categAgent.py", line 203, in <module>
gradient_steps=20) # number of steps for BPTT to unroll network
File
"/home/madvn/anaconda2/lib/python2.7/site-packages/lasagne/layers/recurrent.py",
line 552, in __init__
in_to_hid = DenseLayer(InputLayer((None,) + input_shape[2:]),
TypeError: can only concatenate tuple (not "list") to tuple
Please help. Thanks
- Madhavun
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...