Skip to Main Content
Hands-On Artificial Intelligence for Beginners
book

Hands-On Artificial Intelligence for Beginners

by David Dindi, Patrick D. Smith
October 2018
Beginner content levelBeginner
362 pages
9h 32m
English
Packt Publishing
Content preview from Hands-On Artificial Intelligence for Beginners

Training Word2vec models

As Word2vec models are neural networks themselves, we train them just like a standard feedforward network with a loss function and stochastic gradient descent. During the training process, the algorithm scans over the input corpus and takes batches of it as input. After each batch, a loss is calculated. When optimizing, we want to minimize our loss as we would with a standard feedforward neural network.

Let's walk through how we would create and train a Word2vec model in TensorFlow:

  1. First, let's start with our imports. We'll use our standard tensorflow and numpy imports and the Python library itertools, as well as two utility functions from the machine learning package scikit-learn. The following code block shows ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Artificial Intelligence and Machine Learning Fundamentals

Artificial Intelligence and Machine Learning Fundamentals

Zsolt Nagy

Publisher Resources

ISBN: 9781788991063Supplemental Content