testCase neural-network

This commit is contained in:
s452693 2021-06-21 10:57:23 +02:00
parent 1f68e0d82d
commit 0290293ca0

View File

@ -131,43 +131,52 @@ def testing(n, testingSamples, testingLabels):
testing(digitNetwork,dig_test_images,dig_test_labels)
li = []
ourOwnDataset = []
record_cache = None
def testCase(inputWord):
len = len(inputWord)
li = []
ourOwnDataset = []
word = ""
for i in range(0,len-2):
imgArray = imageio.imread(imageFileName, as_gray=True)
for i in len-2:
imgData = 255 - imgArray.reshape(784)
imgData = (imgData/255 * 0.99) + 0.01
word = word + recognizeLet(inputWord[i],imgData)
word = word + recognizeNum[inputWord[-2]]
word = word + recognizeNum[inputWord[-1]]
#inputWord[i]
word = word + recognizeLet(letterNetwork ,imgData)
word = word + recognizeNum(digitNetwork, inputWord[-2])
word = word + recognizeNum(digitNetwork ,inputWord[-1])
assert record_cache.shape == ourOwnDataset[0].shape
labelInput = np.asfarray(li)
#assert record_cache.shape == ourOwnDataset[0].shape
#labelInput = np.asfarray(li)
#print(labelInput)
print('slowo: ', word)
pass
def recognizeLet(let,imgData):
def recognizeLet(n,imgData):
letters=['','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
record = np.append(label,imgData)
#record = np.append(label,imgData)
outputs = n.query(imgData)
label = np.argmax(outputs)
return letters[int(label)]
def recognizeNum():
def recognizeNum(n, imgData):
pass
record = np.append(label,imgData)
#record = np.append(label,imgData)
outputs = n.query(imgData)
#print('Record: ',record)
ourOwnDataset.append(record)
if record_cache is None:
record_cache = record
#ourOwnDataset.append(record)
#if record_cache is None:
# record_cache = record
#print(ood[0])
li.append(label)
#li.append(label)
label = np.argmax(outputs)
return str(label)
pass