imdb


imdb, a keras code which sets up a neural network to classify movie reviews from the IMDB database. This version tries to use a downloaded copy of the database.

This script references the keras imdb dataset. By default, this is stored in the location ~/.keras/datasets, and involves two files, imdb.npz, and imdb_word_index.json. If these files are not there at run time, keras will attempt to download them to that location from a server, before proceeding.

If you are using a remote computing site, then the nodes of that site may be restricted from internet access. That means that, at run time, if keras cannot find the datasets it needs, it will be unable to download copies, and hence the job will fail. This version of the movie review code is intended to be run in such a situation.

Two steps were required to get the program to run:

  1. The code was first run on a system that had internet access, so that copies of the dataset were stored locally. These local files were then copied to a corresponding directory on the remote computing site.
  2. The first run on the remote computing site failed, because np.load() has a default setting "allow_pickle=False". A way around this issue was discovered, which essentially involves temporarily redefining np.load() with "allow_pickle=True".

The original code, available as "movie_review", also created two matplotlib plots during the run. For this version of the code, those plots were suppressed.

Licensing:

The information on this web page is distributed under the MIT license.

Related Data and Programs:

boston, a keras code which sets up a neural network to apply regression to predict housing prices, based on the Boston housing dataset, as read from internal data functions.

boston_housing, a keras code which sets up a neural network to apply regression to predict housing prices, based on the Boston housing dataset.

boston_housing_external, a keras code which reads the Boston housing dataset from an external file, rather than referencing the built-in keras dataset, and applies regression to predict housing prices

dogs_vs_cats_data, a keras code which sets up test, train, and valid directories with data for the dogs versus cats example.

dogs_vs_cats1, a keras code which sets up a convolutional neural network to classify jpeg images as being of dogs or of cats.

hello_keras, a keras code which loads keras, says hello, and exits.

hourly_wages, a keras code which uses a neural network to create a multivariable regression model from a set of hourly wage data.

imdb_dataset_load, a keras code which can download a copy of the IMDB dataset and place it in the default location if that has not already been done.

imdb_decode, a keras code which shows how to decode an IMDB dataset movie review.

mnist, a keras code which sets up a neural network to classify the MNIST digit image data.

mnist_convnet, a keras code which sets up a convolutional neural network to classify the MNIST digit image data.

montana, a keras code which seeks a regression formula y = b + w * x, using data supplied in an internal function.

movie_review, a keras code which sets up a neural network to classify movie reviews from the IMDB database.

newswire, a keras code which sets up a neural network for the classification of Reuters newswire texts into one of 46 categories.

paraheat_gaussian_parameter, a keras code which reads data for the heat equation with a parameterized gaussian diffusivity, and uses a neural network to estimate a single parameter from solution values at sensor locations.

paraheat_gaussian_parameters, a keras code which reads data for the heat equation with a parameterized gaussian diffusivity, and uses a neural network to estimate four parameters from solution values at sensor locations.

regression_1d, a keras code which reads training and test files of data pairs (x,y), and seeks a regression formula y = b + w * x.

Author:

The original text is by Francois Chollet; some modification were made by John Burkardt.

Reference:

  1. Francois Chollet,
    Deep Learning with Python,
    Manning, 2018,
    ISBN: 9781617294433.

Source Code:


Last revised on 12 November 2019.