makeyourownneuralnetwork/makeyourownneuralnetwork

print my label

Closed this issue · 3 comments

Hello,
in the code part 'test the neural network' I put code to print also my number the network has to guess (the images itself)

_# test the neural network

_# scorecard for how well the network performs, initially empty
scorecard = []

_# go through all the records in the test data set
for record in test_data_list:
# split the record by the ',' commas
all_values = record.split(',')
# correct answer is first value
correct_label = int(all_values[0])
print(correct_label, "is correct label")

image_array = numpy.asfarray(all_values[1:]).reshape(28,28)
matplotlib.pyplot.imshow(image_array, cmap='Greys',interpolation='None')

# scale and shift the inputs
inputs = (numpy.asfarray(all_values[1:]) / 255.0 * 0.99) + 0.01
# query the network
outputs = n.query(inputs)
# the index of the highest value corresponds to the label
label = numpy.argmax(outputs)
print(label, "network's answer")
# append correct or incorrect to list
if (label == correct_label):
    # network's answer matches correct answer, add 1 to scorecard
    **scorecard.append(1)**
else:
    # network's answer doesn't match correct answer, add 0 to scorecard
    scorecard.append(0)
    pass

pass

However when I run the code only the last record is printed as an image. But the code is put into the loop. How comes only my last record of the test set has been printed? See attach!


output

matplotlib will overwrite the "graph" with the most recent plot.

to plot many you need to have a multi-graph, see google as I can't remember how to do it

Hello Rashid,
I found the answer in meanwhile.
All you have to do is adding the line of code:
matplotlib.pyplot.imshow()

That's all.

BTW: is there a forum where we can discuss ipython code (and then in general regarding neural networks). Because I think I bother you too much when I allways have to ask you how to do this or how to do that :-(

thats good!

try reddit - i'm told there's a lot of discussion there.

myself i prefer meetups and hackathons which you might also prefer