Professional Documents
Culture Documents
DL Lab Ex - No.5
DL Lab Ex - No.5
Build a Deep Neural Network for multi class text classification using Reuters
dataset. Plot the results in the graph.
Aim :- Build a Deep Neural Network for multi class text classification using Reuters
dataset.
Algorithm :-
1. Import the necessary libraries, including tensorflow, keras, and the Reuters dataset.
2. Preprocess the data by tokenizing the text, converting the input sequences into fixed-length
sequences, and encoding the target labels.
3. Define the architecture of the deep neural network. This involves specifying the number of
layers, the number of neurons in each layer, the activation function, and any regularization
techniques such as dropout or batch normalization.
4. Compile the model by specifying the loss function, the optimizer, and the evaluation metric.
5. Train the model using the training data. This involves specifying the batch size, the number
of epochs, and the validation split.
7.Optionally, fine-tune the hyperparameters of the model using techniques such as grid search
or Bayesian optimization.
Program :
import numpy as np
import matplotlib.pyplot as plt
from keras.datasets import reuters
from keras.models import Sequential
from keras.layers import Dense, Embedding, LSTM, SpatialDropout1D
from keras.preprocessing.text import Tokenizer
from keras.preprocessing.sequence import pad_sequences
from keras.utils import to_categorical