An LSTM coordinate has c=1 before a padded step. During padding the input is
zero and the gates are f=0.5, i=0.5, o=0.75 with candidate 0.6. The
next real step has f=0.5, i=0.5, candidate 0 and o=0.75. Compare the
next real hidden state when the padded step updates c but freezes h, and
when it freezes both.
Hint
Freezing h alone still runs the cell update.
Solution
Freezing only h: the padded step computes c=0.5⋅1+0.5⋅0.6=0.8.
The next real step gives c=0.5⋅0.8=0.4 and
h=0.75tanh(0.4)=0.284962.
Freezing both: the cell stays at 1, the next step gives c=0.5 and
h=0.75tanh(0.5)=0.346588.
The masked update of I.9 applied to h alone is not enough for an LSTM.
Mask both states: if ctnew is the cell update the step
computed, keep mtctnew+(1−mt)ct−1, and apply the
same rule to ht. Or pack the sequence so padded steps never run.