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.

Training and evaluating the model

Training and evaluating the model

- [Instructor] With our datasets all set up, we are now ready to train our sentiment analysis model. We'll use the same Dense neural network as before, no change in the architecture. The only change here is how we have encoded the input text. We've used TF-IDF vectorization instead of count vectorization. The first block of code is where we set up our DNN model. The first Dense layers have tanh activation, and the last Dense layer with three units is the output layer. The output is in the raw logits form. The Dense neural network has the same two dropout layers with 10% dropout. We call model.compile. We configure the parameters for training the model. The same SparseCategoricalCrossentropy loss from logits is equal to true because we are not using softmax activation as our last layers, so the output scores will be raw logit scores rather than normalized probabilities. We use the Adam optimizer with a learning rate of…

Contents