Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Deep Learning for Natural Language Processing
  • Table Of Contents Toc
  • Feedback & Rating feedback
Deep Learning for Natural Language Processing

Deep Learning for Natural Language Processing

By : Karthiek Reddy Bokka, Shubhangi Hora , Tanuj Jain, Monicah Wambugu
1.5 (2)
close
close
Deep Learning for Natural Language Processing

Deep Learning for Natural Language Processing

1.5 (2)
By: Karthiek Reddy Bokka, Shubhangi Hora , Tanuj Jain, Monicah Wambugu

Overview of this book

Applying deep learning approaches to various NLP tasks can take your computational algorithms to a completely new level in terms of speed and accuracy. Deep Learning for Natural Language Processing starts by highlighting the basic building blocks of the natural language processing domain. The book goes on to introduce the problems that you can solve using state-of-the-art neural network models. After this, delving into the various neural network architectures and their specific areas of application will help you to understand how to select the best model to suit your needs. As you advance through this deep learning book, you’ll study convolutional, recurrent, and recursive neural networks, in addition to covering long short-term memory networks (LSTM). Understanding these networks will help you to implement their models using Keras. In later chapters, you will be able to develop a trigger word detection application using NLP techniques such as attention model and beam search. By the end of this book, you will not only have sound knowledge of natural language processing, but also be able to select the best text preprocessing and neural network models to solve a number of NLP issues.
Table of Contents (11 chapters)
close
close

Flask

In this section, we will use the Flask microserver framework provided by Python to make a web application that provides predictions. We will get a RESTful API that we can query to get our results. Before commencing, we need to install Flask (use pip):

  1. Let's begin by importing the packages:

    import re

    import pickle

    import numpy as np

    from flask import Flask, request, jsonify

    from keras.models import load_model

    from keras.preprocessing.sequence import pad_sequences

  2. Now, let's write a function that loads the trained model and tokenizer:

    def load_variables():

    global model, tokenizer

    model = load_model('trained_model.h5')

    model._make_predict_function() #https://github.com/keras-team/keras/issues/6462

    with open('trained_tokenizer.pkl', 'rb') as f:

    tokenizer = pickle.load(f)

    The make_predict_function() is a hack that allows using keras models with Flask.

  3. Now, we'll define preprocessing functions similar to the training code...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY