You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature suggestion: expose weights for RNNCell #812
I realize that the API for RNNs hasn't been finalized yet but eventually it would be nice if the weights of the RNNCell are exposed so that they can be tracked using the summary ops like histogram_summary. Maybe just a property that returns all the internal weights.
You can already retrieve the weights easily with variable scope, e.g.:
cell = RNNCell(...)
with tf.variable_scope("RNN") as vs:
# use cell here.
for var in tf.trainable_variables():
if var.name.startswith(vs.name):
print var.name, var.get_shape()
tf.histogram_summary(var.name, var)
That's a nice way to track everything, thanks. My initial point wasn't that it's impossible, but that it would be useful to provide a convenient mechanism to get at the variables for a specific cell.
Yes, I understand. For common use cases this doesn't seem to be needed .. and you can always use variable scope to get specific variables, like: rnn_matrix = tf.get_variable(vs.name + "/Matrix") but you need to be in the proper scope and know the names.
With the current design, the rnn cells are not associated with any specific variables (and are stateless) unless in a specific variable scope so having properties to keep references to them sounds hacky as well.
In tensorboard, if you use the LSTMCell class of tensorflow you can visualize the kernel variable in tensorboard.
You can instead define your weights in the call method. By saying weights I mean the W_xh and W_hh.
Activity
rafaljozefowicz commentedon Jan 19, 2016
You can already retrieve the weights easily with variable scope, e.g.:
alquraishi commentedon Jan 19, 2016
This strikes me as a very hacky solution.
rafaljozefowicz commentedon Jan 19, 2016
If you just need histogram summaries for all the variables, then you don't need to use it in any specific variable scopes:
alquraishi commentedon Jan 19, 2016
That's a nice way to track everything, thanks. My initial point wasn't that it's impossible, but that it would be useful to provide a convenient mechanism to get at the variables for a specific cell.
rafaljozefowicz commentedon Jan 19, 2016
Yes, I understand. For common use cases this doesn't seem to be needed .. and you can always use variable scope to get specific variables, like:
rnn_matrix = tf.get_variable(vs.name + "/Matrix")but you need to be in the proper scope and know the names.With the current design, the rnn cells are not associated with any specific variables (and are stateless) unless in a specific variable scope so having properties to keep references to them sounds hacky as well.
alquraishi commentedon Jan 19, 2016
Ok. Thanks for clarifying.
ziofil commentedon Jan 28, 2018
Two years later now. Is there a better solution or should we still use the code in @rafaljozefowicz 's example?
matthijsvk commentedon Apr 4, 2018
I'm looking for a better solution to this as well
AzizCode92 commentedon Nov 21, 2018
In tensorboard, if you use the LSTMCell class of tensorflow you can visualize the kernel variable in tensorboard.
You can instead define your weights in the call method. By saying weights I mean the W_xh and W_hh.
and then during training, you add
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA
Update XNNPACK in XLA