October 2018
Intermediate to advanced
472 pages
10h 57m
English
Again, most of the code will remain same—the only the major change will be to use tf.nn.rnn_cell.LSTMCell(), instead of tf.nn.rnn_cell.BasicRNNCell(). While initializing the LSTM cell, we are using an orthogonal initializer that will generate a random orthogonal matrix, which is an effective way of combating exploding and vanishing gradients:
class Model: def __init__(self, size_layer, num_layers, embedded_size, dict_size, dimension_output, learning_rate): def cells(reuse=False): return tf.nn.rnn_cell.LSTMCell(size_layer,initializer=tf.orthogonal_initializer(),reuse=reuse) self.X = tf.placeholder(tf.int32, [None, None]) self.Y = tf.placeholder(tf.float32, [None, dimension_output]) encoder_embeddings = tf.Variable(tf.random_uniform([dict_size, ...
Read now
Unlock full access