Here is my code:
trainingSet = {"0,0":0, "1,0":1, "2,0":1, "0,1":0, "1,1":1, "1,2":0, "2,0":0, "2,1":0, "2,2":1}
for k,expectedOutput in trainingSet.iteritems():
print 1
coordinates = k.split(",")
network.layers[0].neurons[0].value = float(coordinates[0])
network.layers[0].neurons[1].value = float(coordinates[1])
output = network.calculateOutput()
The output is:
1
1
1
1
1
1
1
1
# 8 lines
How is that possible? There are 9 items in the trainingSet dictionary. Shouldn’t the output be:
1
1
1
1
1
1
1
1
1
# 9 lines
You have the key “2,0” twice:
The keys in a dictionary must be unique. If you want to have a key more than once with different values you need to use a different data structure. You could use for example a list of tuples, or a dictionary from the key to a list of values.
More likely though I guess you just mixed up the numbers and you actually meant something like this: