subject

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])

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:50, OnlyaBurden
In this lab, you complete a prewritten c++ program for a carpenter who creates personalized house signs. the program is supposed to compute the price of any sign a customer orders, based on the following facts: the charge for all signs is a minimum of $35.00. the first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. if the sign is made of oak, add $20.00. no charge is added for pine. black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering. instructions ensure the file named housesign. cppis open in the code editor. you need to declare variables for the following, and initialize them where specified: a variable for the cost of the sign initialized to 0.00 (charge). a variable for the number of characters initialized to 8 (numchars). a variable for the color of the characters initialized to "gold" (color). a variable for the wood type initialized to "oak" (woodtype). write the rest of the program using assignment statements and ifstatements as appropriate. the output statements are written for you. execute the program by clicking the run button. your output should be: the charge for this sign is $82. this is the code, // housesign. cpp - this program calculates prices for custom made signs. #include #include using namespace std; int main() { // this is the work done in the housekeeping() function // declare and initialize variables here // charge for this sign // color of characters in sign // number of characters in sign // type of wood // this is the work done in the detailloop() function // write assignment and if statements here // this is the work done in the endofjob() function // output charge for this sign cout < < "the charge for this sign is $" < < charge < < endl; return(0); }
Answers: 1
image
Computers and Technology, 22.06.2019 19:30, 710jonathan
The following is an excerpt from a slide presentation. today we will inverse operations solving equations using inverse operations solving inequalities using inverse operations from which part of the presentation does the slide most likely come from? a. introduction b. outline c. body d. conclusion
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, Alexaisokay1
In which of the following ways can using test-taking tips you? a. you can focus on the information that you need to study. b. you will see the answers to the test. c. you will study more. d. you will be less organized.
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, nayo2006
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
You know the right answer?
Run the code in your Jupyter Notebook. Follow the examples in the book to establish an accuracy rate...

Questions in other subjects: