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

Putting it together

We can then write an inference method to bring together the various modules into a single pipeline for reading inputs and questions, obtaining context vectors, and producing an output:

    def _inference(self, facts, questions):        with tf.variable_scope("MemoryNetwork"):            input_vectors = self._input_module(facts)            question_vectors = self._question_module(questions)            context_vectors = self._memory_module(question_vectors,                                                   input_vectors)            output = self._output_module(context_vectors)            return output

Lastly, we define the fit and predict functions, which can be used to train and make predictions using the memory network as part of a larger pipeline. We use a feed_dict to pass data into the operations that we had defined in the initialization ...

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