Making predictions on sample review texts

Now, let's take a look at how our trained model generalizes, that is, how it performs on unseen review texts from the sentiment labeled sentences dataset. First, we need to restore the trained model from the disk:

System.out.println("Starting the evaluation on sample texts ...");boolean saveUpdater = true;MultiLayerNetwork restoredModel = ModelSerializer.restoreMultiLayerNetwork(modelPath, saveUpdater);SentimentDatasetIterator test = new SentimentDatasetIterator(DATA_PATH, wordvectors, batchSize,                                                              truncateReviewsToLength, false);

Now, we can randomly extract two review texts from IMDb, Amazon, and Yelp, where the first one expresses a positive sentiment, and the second one expresses a negative sentiment ...

Get Java Deep Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.