O'Reilly logo

Hands-On Natural Language Processing with Python by Rajalingappaa Shanmugamani, Rajesh Arumugam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Class constructor

We will define the constructor for initializing the memory network's initializer object, optimizer object, mini-batch size, and so on. We will also write high-level TensorFlow operations for the loss, prediction, and training. All of them hinge on the _inference method, which we will implement in the following sections:

class MemoryNetwork(object):    def __init__(self, sentence_size, vocab_size, candidates_size,                  candidates_vec, embedding_size, hops,                  initializer=tf.random_normal_initializer(stddev=0.1),                  optimizer=tf.train.AdamOptimizer(learning_rate=0.01),                 session=tf.Session()):        self._hops = hops        self._candidates_vec = candidates_vec                # Define placeholders for inputs to the model        self._facts = tf.placeholder( tf.int32, [None, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required