Book Image

Neural Networks with Keras Cookbook

By : V Kishore Ayyadevara
Book Image

Neural Networks with Keras Cookbook

By: V Kishore Ayyadevara

Overview of this book

This book will take you from the basics of neural networks to advanced implementations of architectures using a recipe-based approach. We will learn about how neural networks work and the impact of various hyper parameters on a network's accuracy along with leveraging neural networks for structured and unstructured data. Later, we will learn how to classify and detect objects in images. We will also learn to use transfer learning for multiple applications, including a self-driving car using Convolutional Neural Networks. We will generate images while leveraging GANs and also by performing image encoding. Additionally, we will perform text analysis using word vector based techniques. Later, we will use Recurrent Neural Networks and LSTM to implement chatbot and Machine Translation systems. Finally, you will learn about transcribing images, audio, and generating captions and also use Deep Q-learning to build an agent that plays Space Invaders game. By the end of this book, you will have developed the skills to choose and customize multiple neural network architectures for various deep learning problems you might encounter.
Table of Contents (18 chapters)

Building a word vector using the skip-gram and CBOW models

In the previous recipe, we built a word vector. In this recipe, we'll build skip-gram and CBOW models using the gensim library.

Getting ready

The method that we have adopted to build a word vector in this recipe is called a continuous bag of words (CBOW) model. The reason it is called as CBOW is explained as follows:

Let's use this sentence as an example: I enjoy playing TT.

Here's how the CBOW model handles this sentence:

  1. Fix a window of certain size—let's say 1.
    • By specifying the window size, we are specifying the number of words that will be considered to the right as well as to the left of the given word.
  2. Given the window size, the...