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

The class constructor lets us load the data and candidates, and then build a vocabulary and subsequently initialize our TensorFlow session and memory network object:

class ChatBotWrapper(object):    def __init__(self, train_data, test_data, val_data,                  candidates, candidates_to_idx,                 memory_size, batch_size, learning_rate,                  evaluation_interval, hops,                 epochs, embedding_size):        self.memory_size = memory_size        self.batch_size = batch_size        self.evaluation_interval = evaluation_interval        self.epochs = epochs        self.candidates = candidates         self.candidates_to_idx = candidates_to_idx        self.candidates_size = len(candidates)        self.idx_to_candidates = dict((self.candidates_to_idx[key], key)                                       for key in self.candidates_to_idx) # Initialize data ...

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