def RNN(tensor, lens, n_hidden, n_summary, name, reuse):
with tf.variable_scope(name, reuse) as scope:
# Define weights
weights = {
'out': tf.Variable(tf.random_normal([n_hidden, n_summary]), name=name+"_weights")
}
biases = {
'out': tf.Variable(tf.random_normal([n_summary]), name=name+"_biases")
}
# Define a lstm cell with tensorflow
lstm_cell = rnn_cell.LSTMCell(n_hidden, forget_bias=1.0, state_is_tuple=True)
# Get lstm cell output
outputs, states = rnn.rnn(lstm_cell, tensor, sequence_length=lens, dtype=tf.float32, scope=scope)
# Linear activation, using rnn inner loop last output
return tf.matmul(outputs[-1], weights['out']) + biases['out']
# Now for parts specific to this data
# Parameters
评论列表
文章目录