From the course: Deep Learning with Python and Keras: Build a Model for Sentiment Analysis

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Configuring the count vectorizer as a model layer

Configuring the count vectorizer as a model layer

- [Narrator] I'll evaluate the model on the test dataset once again, but I'll show you a slightly different configuration for our model. In the previous example, we performed the pre-processing of text as a part of the dataset itself. In this example, I'm doing things a little differently. Ideally, you'd want your model itself to be capable of reprocessing the text data that is fed into the model, and this can be done by making the count vectorizer a layer in your model. This is what I've done here. Notice the export model is a sequential model that applies the count vectorizer as a layer, followed by our dense neural network model model. If you were to deploy this export model, you'd be able to feed in raw strings that would be pre-processed using our count vectorizer. Having the pre-processing as a part of the model itself makes it easier to use the model. I call model.compile to configure the model with various…

Contents