Reputation: 75
I am trying to figure out how a fully-functional python code works. One block creates a LSTM cell using tensorflow. I don't know how to interpret the line specified by the comment below.
def get_lstm_weights(n_hidden, forget_bias, dim, scope="rnn_cell"):
# Create LSTM cell
cell = tf.contrib.rnn.LSTMCell(num_units = n_hidden, reuse=None, forget_bias = forget_bias)
#--------------------------------------
# I DO NOT UNDERSTAND THE NEXT LINE
cell(tf.zeros([1, dim +1]), (tf.zeros([1, n_hidden]),tf.zeros([1, n_hidden])), scope=scope)
# -------------------------------------
cell = tf.contrib.rnn.LSTMCell(num_units = n_hidden, reuse=True, forget_bias = forget_bias)
# Create output weights
weights = {
'W_1': tf.Variable(tf.truncated_normal([n_hidden, dim], stddev=0.05)),
'b_1': tf.Variable(0.1*tf.ones([dim])),
}
return cell, weights
Upvotes: 3
Views: 62
Reputation: 14525
Note that tf.contrib.rnn.LSTMCell
is an example of a callable class.
That is a class that can be called like a function. The line you are struggling with does exactly that. It calls cell
with the parameters in brackets.
If you want to see what this does you can inspect the __call__
method on the class definition for tf.contrib.rnn.LSTMCell
Upvotes: 1