Training and Evaluating GloVe

Learn how to train and evaluate the model with the GloVe algorithm.

Validation call back function

Training the model is effortless because we have all the components needed to train it. As the first step, we’ll reuse the ValidationCallback() we created. To recap, ValidationCallback() is a Keras callback. Keras callbacks give us a way to execute some important operations at the end of every training iteration, epoch, prediction step, etc. Here, we’re using the callback to perform a validation step at the end of every epoch. Our callback would take a list of word IDs intended as the validation words (held out in valid_term_ids), the model containing the embedding matrix, and a tokenizer to decode word IDs. Then it will compute the most similar top kk words for every word in the validation word set and print that as the output:

Get hands-on with 1200+ tech skills courses.