I am trying to add the weights and biases to tensorboard according to the layers. The following way I tried:
tf.reset_default_graph()
X = tf.placeholder(tf.float32, [None, n_steps, n_inputs])
y = tf.placeholder(tf.float32, [None,n_outputs])
layers = [tf.contrib.rnn.LSTMCell(num_units=n_neurons,
activation=tf.nn.leaky_relu, use_peepholes = True)
for layer in range(n_layers)]
# for i, layer in enumerate(layers):
# tf.summary.histogram('layer{0}'.format(i), tf.convert_to_tensor(layer))
multi_layer_cell = tf.contrib.rnn.MultiRNNCell(layers)
for index,one_lstm_cell in enumerate(multi_layer_cell):
one_kernel, one_bias = one_lstm_cell.variables
# I think TensorBoard handles summaries with the same name fine.
tf.summary.histogram("Kernel", one_kernel)
tf.summary.histogram("Bias", one_bias)
rnn_outputs, states = tf.nn.dynamic_rnn(multi_layer_cell, X, dtype=tf.float32)
stacked_rnn_outputs = tf.reshape(rnn_outputs, [-1, n_neurons])
stacked_outputs = tf.layers.dense(stacked_rnn_outputs, n_outputs)
outputs = tf.reshape(stacked_outputs, [-1, n_steps, n_outputs])
outputs = outputs[:,n_steps-1,:] # keep only last output of sequence
But I got the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-43-761df6e116a7> in <module>()
44
45 multi_layer_cell = tf.contrib.rnn.MultiRNNCell(layers)
---> 46 for index,one_lstm_cell in enumerate(multi_layer_cell):
47 one_kernel, one_bias = one_lstm_cell.variables
48 # I think TensorBoard handles summaries with the same name fine.
TypeError: 'MultiRNNCell' object is not iterable
I would like to know what I have missed so that I can add the variables for visualization in the tensorboard. Kindly, help me.