# What ANN layer widths support the learning of digit recognition?

I have created an ANN in Python (without libs). On beginning, it had been learned in target of solve linear problems like distinguishing between negative and positive numbers, where the layer widths were [1, 2, 1]. I have decided to learn recognizing small digits saved as 20x20 black & white PNG files. Now the array of layer widths is:

[1200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 10]


I tried other similar ones.... With the above array of layer widths training took 8 hours (NN had seen 600.000 images from 5000 images of learning set) and when I look at results, each output is equal about 10%-15%. Nothing is certain.

This code is a core of my NN

and that is main code:

net = nnmv.NeuralNetwork()
net.createNew([1200,100,100,100,100,100,100,100,100,100,100,100,100,10],0.15,0.07)
for step in range(0,1000):
for i in range(0,500):
for number in range(0,10):
print("Currently learning: ",number,'x',i," in step: ",step)
pixels = list(Image.open("judgment/"+str(number)+'x'+str(i)+".png").convert("RGB").getdata())
output = list()
for itr in range(0,number):
output.append(0)
output.append(1)
for itr in range(0,9-number):
output.append(0)
net.teach(Stuff.reorganisePixelData(pixels),output)
print("Error: ",net.calculateError(output))
Saver.Saver().save(net, "digitrecognizer")


There is 1200 inputs because there are 400 pixels and each pixel is saved in RGB model. Stuff.reorganisePixelData:

def reorganisePixelData(pixels):
output = []
for i in range(0,len(pixels)):
output.append(pixels[i][0])
output.append(pixels[i][1])
output.append(pixels[i][2])
return output


What have I to do? Add or remove layers, change some or all of the layer widths? Or something in concept of learning?

My error calculator prints error like 0.30203135930914193, and it changes only a bit.

• Welcome to AI.SE! I'm sorry, this site focuses on social/architectural/scientific questions about artificial intelligence, as opposed to implementation/programming issues. For the latter, you might be able to get help on Data Science. For an intro to our site, see the tour. – Ben N Jul 27 '18 at 16:21
• Ok, but this question is not off-topic. It is about architectural problem, the code is only addon for present the problem! – mvxxx Jul 27 '18 at 18:35
• Ah, I see. Sorry about that, reopened! – Ben N Jul 27 '18 at 18:37
• Just wanted to check in to make sure the recent edit to your question is acceptable. (You can roll back the edit if you desire.) – DukeZhou Aug 13 '18 at 20:49