Professional Documents
Culture Documents
7 Sharpen 1 Epoch
7 Sharpen 1 Epoch
localhost:8888/notebooks/Downloads/Untitled6.ipynb?kernel_name=python3 1/6
11/24/22, 8:18 PM Untitled6 - Jupyter Notebook
return conv_image
localhost:8888/notebooks/Downloads/Untitled6.ipynb?kernel_name=python3 2/6
11/24/22, 8:18 PM Untitled6 - Jupyter Notebook
2
# calculate signals into final output layer
final_inputs = numpy.dot(self.who, hidden_outputs)
# calculate the signals emerging from final output layer
final_outputs = self.activation_function(final_inputs)
# update the weights for the links between the hidden and output laye
self.who += self.lr * numpy.dot((output_errors * final_outputs * (1.0
# update the weights for the links between the input and hidden layer
self.wih += self.lr * numpy.dot((hidden_errors * hidden_outputs * (1.
return final_outputs
localhost:8888/notebooks/Downloads/Untitled6.ipynb?kernel_name=python3 3/6
11/24/22, 8:18 PM Untitled6 - Jupyter Notebook
# taking all but first element (label). Then, scaling and shifting ea
inputs = ((training_data[r][1:]) / 255.0 * 0.99) + 0.01
# create the target output values (all 0.01, except the desired label
targets = numpy.zeros(output_nodes) + 0.01
# training_data[0] is the target label for this record
targets[training_data[r][0]] = 0.99
n.train(inputs, targets)
pass
pass
# test the neural network
# scorecard for how well the network performs, initially an empty list
scorecard = []
#building an empty array to add output rows to
predicted = numpy.empty((0,40), int)
Output_Matrix = numpy.zeros((40,40)) # Building an empty 40x40 matrix to fill
# go through all the images in the test data set one by one
for r in range(len(testing_data)):
#???
correct_label = testing_data[r][0]
# scale and shift the input image values
inputs = ((testing_data[r][1:]) / 255.0 * 0.99) + 0.01
# pre-processing the inputs with convolution
inputs = n.conv_func(inputs)
# query the network
outputs = n.query(inputs)
predicted = numpy.append(predicted, outputs)
# takes the highest value in the output node for the specific image being
label = numpy.argmax(outputs)
localhost:8888/notebooks/Downloads/Untitled6.ipynb?kernel_name=python3 4/6
11/24/22, 8:18 PM Untitled6 - Jupyter Notebook
performance = 53.790983606557376
1.7979512565347056
Out[144]: <AxesSubplot:>
localhost:8888/notebooks/Downloads/Untitled6.ipynb?kernel_name=python3 5/6
11/24/22, 8:18 PM Untitled6 - Jupyter Notebook
In [ ]:
localhost:8888/notebooks/Downloads/Untitled6.ipynb?kernel_name=python3 6/6