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

Generating word embeddings

For our embedding scheme, we are going to be using the implementation of GloVe from the previous chapter:

from collections import Counter, defaultdictimport osfrom random import shuffleimport tensorflow as tfimport nltk
class GloVeModel(): def __init__(self, embedding_size, window_size, max_vocab_size=100000, min_occurrences=1, scaling_factor=3/4, cooccurrence_cap=100, batch_size=512, learning_rate=0.05): self.embedding_size = embedding_size#First we define the hyper-parameters of our model if isinstance(context_size, tuple): self.left_context, self.right_context = context_size elif isinstance(context_size, int): self.left_context = self.right_context = context_size   self.max_vocab_size = max_vocab_size self.min_occurrences ...
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