Tensorflow: show or save forget gate values in LSTM
<p>I am using the LSTM model that comes by default in tensorflow. I would like to check or to know how to save or show the values of the forget gate in each step, has anyone done this before or at least something similar to this?</p>

<p>Till now I have tried with tf.print but many values appear (even more than the ones I was expecting) I would try plotting something with tensorboard but I think those gates are just variables and not extra layers that I can print (also cause they are inside the TF script)</p>

<p>Any help will be well received</p>

<p>If you are using <code>tf.rnn_cell.BasicLSTMCell</code> , the variable you are looking for will have the following suffix in its name : <code>&lt;parent_variable_scope&gt;/BasicLSTMCell/Linear/Matrix</code> . This is a concatenated matrix for all the four gates. Its first dimension matches the sum of the second dimensions of the input matrix and the state matrix (or output of the cell to be exact). The second dimension is 4 times the number of cell size.</p>

<p>The other complementary variable is <code>&lt;parent_variable_scope&gt;/BasicLSTMCell/Linear/Bias</code> that is a vector of the same size as the second dimension of the abovementioned tensor (for obvious reasons).</p>

<p>You can retrieve the parameters for the four gates by using <code>tf.split()</code> along dimension 1. The split matrices would be in the order <code>[input], [new input], [forget], [output]</code>. I am referring to the code here form <code>rnn_cell.py</code>.</p>

<p>Keep in mind that the variable represents the parameters of the Cell and not the output of the respective gates. But with the above info, I am sure you can get that too, if you so desire.</p>

<p>Edit:<br>
Added more specific information about the actual tensors <code>Matrix</code> and <code>Bias</code></p>

python neural-network tensorflow lstm