the final output layer consists of two units with softmax activation function the softmax function is basically generalization of the logistic function we saw earlierwhich can be used to represent probability distribution over possible class outcomes in our case where the class can either be positive or negative and the softmax probabilities will help us determine the same the binary softmax classifier is also interchangeably known as the binary logistic regression function the compilemethod is used to configure the learning or training process of the dnn model before we actually train it this involves providing cost or loss function in the loss parameter this will be the goal or objective which the model will try to minimize there are various loss functions based on the type of problem you want to solvefor example the mean squared error for regression and categorical crossentropy for classification check out we will be using categorical_crossentropywhich helps us minimize the error or loss from the softmax output we need an optimizer for helping us converge our model and minimize the loss or error function gradient descent or stochastic gradient descent is popular optimizer we will be using the adam optimizer which only required first order gradients and very little memory adam also uses momentum where basically each update is based on not only the gradient computation of the current point but also includes fraction of the previous update this helps with faster convergence you can refer to the original paper from the metrics parameter is used to specify model performance metrics that are used to evaluate the model when training (but not used to modify the training loss itself let' now build dnn model based on our word vec input feature representations for our training reviews in [ ] v_dnn construct_deepnn_architecture(num_input_features= you can also visualize the dnn model architecture with the help of kerassimilar to what we had done in by using the following code see figure - in [ ]from ipython display import svg from keras utils vis_utils import model_to_dot svg(model_to_dot( v_dnnshow_shapes=trueshow_layer_names=falserankdir='tb'create(prog='dot'format='svg')figure - visualizing the dnn model architecture using keras we will now be training our model on our training reviews dataset of word vec features represented by avg_wv_train_features (step we will be using the fitfunction from keras for the training process and there are some parameters which you should be aware of the epoch parameter indicates one complete forward and backward pass of all the training examples through the network the batch_size parameter indicates the total number of samples which are propagated through the dnn model at time for one backward and forward pass for training the model and updating the gradient thus if you have , observations and your batch size is each epoch will consist of iterations where observations will be passed through the network at time and the weights on the hidden layer units will be updated we also