| 172 | return _x[:, n * dim:(n + 1) * dim] |
| 173 | |
| 174 | def _step(m_, x_, h_, c_): |
| 175 | preact = tensor.dot(h_, tparams[_p(prefix, 'U')]) |
| 176 | preact += x_ |
| 177 | |
| 178 | i = tensor.nnet.sigmoid(_slice(preact, 0, options['dim_proj'])) |
| 179 | f = tensor.nnet.sigmoid(_slice(preact, 1, options['dim_proj'])) |
| 180 | o = tensor.nnet.sigmoid(_slice(preact, 2, options['dim_proj'])) |
| 181 | c = tensor.tanh(_slice(preact, 3, options['dim_proj'])) |
| 182 | |
| 183 | c = f * c_ + i * c |
| 184 | c = m_[:, None] * c + (1. - m_)[:, None] * c_ |
| 185 | |
| 186 | h = o * tensor.tanh(c) |
| 187 | h = m_[:, None] * h + (1. - m_)[:, None] * h_ |
| 188 | |
| 189 | return h, c |
| 190 | |
| 191 | state_below = (tensor.dot(state_below, tparams[_p(prefix, 'W')]) + |
| 192 | tparams[_p(prefix, 'b')]) |