Question: This question asks you to use a Python notebook to answer. Using this ipy Download Using this ipy, answer the below. You are building a
This question asks you to use a Python notebook to answer.
Using this ipy Download Using this ipy, answer the below.
You are building a neural network using the following layers:
A dense layer with units with an input shape of maxwords.
A ReLU activation function
A dropout rate of
Another dense layer with numclasses units
A final activation function with softmax
The network is compiled with categorical crossentropy as the loss function, the Adam optimizer, and accuracy as an evaluation metric.
Hint:
model.compileloss'categoricalcrossentropy',
optimizer'adam',
metricsaccuracy
model.summary
What is the total number of parameters in this neural network?
Please enter your answer as a numeric value. maxwords
batchsize
epochs
printLoading data...
xtrain, ytrainxtest, ytest reuters.loaddatanumwordsmaxwords,
testsplit
printlenxtrain 'train sequences'
printlenxtest 'test sequences'
numclasses npmaxytrain
printnumclasses, 'classes'
printVectorizing sequence data...
tokenizer Tokenizernumwordsmaxwords
xtrain tokenizer.sequencestomatrixxtrain, mode'binary'
xtest tokenizer.sequencestomatrixxtest, mode'binary'
printxtrain shape: xtrain.shape
printxtest shape: xtest.shape
printConvert class vector to class matrix
for use with categoricalcrossentropy
ytrain tfkeras.utils.tocategoricalytrain, numclasses
ytest tfkeras.utils.tocategoricalytest, numclasses
printytrain shape: ytrain.shape
printytest shape: ytest.shape
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
