Computers and Technology

Run the code in your Jupyter Notebook. Follow the examples in the book to establish an accuracy rate for the training, validation, and test data sets with two hidden layers. The remainder of the chapter provides examples of how to modify different parameters within the code (number of hidden layers, hidden neurons, BATCH_SIZE, number of epochs, and so on). Pick one parameter and run two or three different experiments, modifying the parameter values to establish accuracy scores with different parameter values. Make sure that the experiments result in significant changes in accuracy rates. Be sure to place each experiment in a different code block so that your instructor can view all of your changes.
Note: You may have to do some research beyond the information provided in the book to implement these changes.
Create a Markdown cell in your Jupyter Notebook after your code and its outputs. In this cell, explain the changes in accuracy rates by comparing and contrasting your results from Steps 3 and 4. What happens to the accuracy rates for the training, validation, and test data sets as you change the parameters? Why?
Here is the code below
from __future__ import print_function
import numpy as np
from keras. datasets import mnist
from keras. models import Sequential
from keras. layers. core import Dense, Activation
from keras. optimizers import SGD
from keras. utils import np_utils
np. random. seed(1671) # for reproducibility
# network and training
NB_EPOCH = 20
BATCH_SIZE = 128
VERBOSE = 1
NB_CLASSES = 10 # number of outputs = number of digits
OPTIMIZER = SGD() # optimizer, explained later in this chapter
N_HIDDEN = 128
VALIDATION_SPLIT=0.2 # how much TRAIN is reserved for VALIDATION
# data: shuffled and split between train and test sets
(X_train, y_train), (X_test, y_test) = mnist. load_data()
#X_train is 60000 rows of 28x28 values --> reshaped in 60000 x 784
RESHAPED = 784
#
X_train = X_train. reshape(60000, RESHAPED)
X_test = X_test. reshape(10000, RESHAPED)
X_train = X_train. astype('float32')
X_test = X_test. astype('float32')
# normalize
X_train /= 255
X_test /= 255
print(X_train. shape[0], 'train samples')
print(X_test. shape[0], 'test samples')
# convert class vectors to binary class matrices
Y_train = np_utils. to_categorical(y_train, NB_CLASSES)
Y_test = np_utils. to_categorical(y_test, NB_CLASSES)
# M_HIDDEN hidden layers
# 10 outputs
# final stage is softmax
model = Sequential()
model. add(Dense(N_HIDDEN, input_shape=(RESHAPED,)))
model. add(Activation('relu'))
model. add(Dense(N_HIDDEN))
model. add(Activation('relu'))
model. add(Dense(NB_CLASSES))
model. add(Activation('softmax'))
model. summary()
model. compile(loss='categorical_crossentr opy',
optimizer=OPTIMIZER,
metrics=['accuracy'])
history = model. fit(X_train, Y_train,
batch_size=BATCH_SIZE, epochs=NB_EPOCH,
verbose=VERBOSE, validation_split=VALIDATION_SPLIT)< br /> score = model. evaluate(X_test, Y_test, verbose=VERBOSE)
print("Test score:", score[0])
print('Test accuracy:', score[1])

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 03:10, nxusasmangaliso8780
Fill in the following program so that it will correctly calculate the price of the orange juice the user is buying based on the buy one get one sale.#include //main functionint main() { int cartons; float price, total; //prompt user for input information printf("what is the cost of one container of oj in dollars? \n"); scanf(" [ select ] ["%d", "%c", "%f", "%lf"] ", & price); printf("how many containers are you buying? \n"); scanf(" [ select ] ["%d", "%c", "%f", "%lf"] ", & cartons); if ( [ select ] ["cartons / 2", "cartons % 1", "cartons % 2", "cartons % price", "cartons / price", "cartons / total"] [ select ] ["=", "==", "! =", "< =", "> =", "< "] 0) total = [ select ] ["price * cartons", "cartons * price / 2 + price", "(cartons / 2) * price", "cartons / (2.0 * price)", "(cartons / 2.0) * price + price", "((cartons / 2) * price) + price"] ; else total = ((cartons / 2) * price) + price; printf("the total cost is $%.2f.\n", total); return 0; }
Answers: 2
image
Computers and Technology, 23.06.2019 04:00, coolconnor1234p0sv4p
Another name for addicting games. com
Answers: 1
image
Computers and Technology, 23.06.2019 07:30, Braxtonw875
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
image
Computers and Technology, 23.06.2019 11:30, magicalpenguin48
In cell h5 enter a formula that will calculate the percentage of attendees that went to the altamonte springs job fair in 2018.
Answers: 1
Do you know the correct answer?
Run the code in your Jupyter Notebook. Follow the examples in the book to establish an accuracy rate...

Questions in other subjects: