# Unable to understand char-lstm example in MXNET for Julia

**URL:** <https://discourse.julialang.org/t/unable-to-understand-char-lstm-example-in-mxnet-for-julia/2186>\
**Category:** Machine Learning\
**Tags:** mxnetjl\
**Created:** [February 20, 2017, 1:53pm UTC](https://discourse.julialang.org/t/unable-to-understand-char-lstm-example-in-mxnet-for-julia/2186 "2017-02-20T13:53:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kishoreabhishek](https://avatars.discourse-cdn.com/v4/letter/k/a88e57/32.png) [@kishoreabhishek](https://discourse.julialang.org/u/kishoreabhishek)\
**Post date:** [February 20, 2017, 1:53pm UTC](https://discourse.julialang.org/t/unable-to-understand-char-lstm-example-in-mxnet-for-julia/2186/1 "2017-02-20T13:53:30Z")

</div>

I am trying to understand the char lstm example mentioned here - [https://github.com/dmlc/MXNet.jl/blob/master/examples/char-lstm/lstm.jl](https://github.com/dmlc/MXNet.jl/blob/master/examples/char-lstm/lstm.jl)

Function lstm\_cell accepts the second parameter as previous state -  
function lstm\_cell(data::mx.SymbolicNode, prev\_state::LSTMState, param::LSTMParam;num\_hidden::Int=512, dropout::Real=0, name::Symbol=gensym())  
However, in the section - #stack LSTM cells

next\_state = lstm\_cell(hidden, l\_state, l\_param, num\_hidden=dim\_hidden, dropout=dp,name=Symbol(name, “lstm$t”))  
hidden = next\_state.h  
layer\_param\_states[i] = (l\_param, next\_state)

layer\_param\_states[i] gets updated with the next state- layer\_param\_states[i] = (l\_param, next\_state)  
why is this done here. Why is the previous state being updated with the next state.
