Mercurial > ift6266
diff deep/amt/amt.py @ 401:86d5e583e278
Fixed class number bug
author | humel |
---|---|
date | Wed, 28 Apr 2010 01:25:52 -0400 |
parents | 99905d9bc9dd |
children | 83413ac10913 |
line wrap: on
line diff
--- a/deep/amt/amt.py Wed Apr 28 00:49:41 2010 -0400 +++ b/deep/amt/amt.py Wed Apr 28 01:25:52 2010 -0400 @@ -10,6 +10,18 @@ turks_per_batch = 3 +def setup_association(): + answer_assoc = {} + for i in range(0,10): + answer_assoc[str(i)]=i + for i in range(10,36): + answer_assoc[chr(i+55)]=i + for i in range(36,62): + answer_assoc[chr(i+61)]=i + return answer_assoc + +answer_assoc = setup_association() + def test_error(): turks = [] reader = csv.DictReader(open(CVSFILE), delimiter=',') @@ -43,15 +55,14 @@ f.close() test_error = 0 for i in range(len(answer_labels)): - try: - answer = int(entry[answer_labels[i]]) - except: - try : - answer = ord(entry[answer_labels[i]]) + answer = entry[answer_labels[i]] + if len(answer) != 0: + try: + if answer_assoc[answer] != int(labels[i]): + test_error+=1 except: test_error+=1 - continue - if answer != int(labels[i]): + else: test_error+=1 return test_error