-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Hello
I'am learning the deep learning models following your code. I have a question while reading the code for lstm. As I understand, in the function lstm_layer, your input state_below
is a 3d tensor with dimension [time_stamp, n_samples, dim_proj]
, this is used in function _step with theano.scan.
rval, updates = theano.scan(_step,
sequences=[mask, state_below],
outputs_info=[tensor.alloc(numpy_floatX(0.),
n_samples,
dim_proj),
tensor.alloc(numpy_floatX(0.),
n_samples,
dim_proj)],
name=_p(prefix, '_layers'),
n_steps=nsteps)
But in the function _step, I saw
preact = tensor.dot(h_, tparams[_p(prefix, 'U')])
preact += x_
i = tensor.nnet.sigmoid(_slice(preact, 0, options['dim_proj']))
f = tensor.nnet.sigmoid(_slice(preact, 1, options['dim_proj']))
o = tensor.nnet.sigmoid(_slice(preact, 2, options['dim_proj']))
c = tensor.tanh(_slice(preact, 3, options['dim_proj']))
c = f * c_ + i * c
c = m_[:, None] * c + (1. - m_)[:, None] * c_
h = o * tensor.tanh(c)
h = m_[:, None] * h + (1. - m_)[:, None] * h_
return h, c
It seems that h_
has the dimension [n_samples, dim_proj]
and x_
is state_below
, how can the h
returned by this function keeps the same dimension and contains the values computed based on x_k
in step k
?
Metadata
Metadata
Assignees
Labels
No labels