Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about Accuracy function #1

Open
dbsxdbsx opened this issue Nov 15, 2017 · 0 comments
Open

Question about Accuracy function #1

dbsxdbsx opened this issue Nov 15, 2017 · 0 comments

Comments

@dbsxdbsx
Copy link

dbsxdbsx commented Nov 15, 2017

for the Accuracy function in cnn_ocr.py.
def Accuracy(label, pred): label = label.T.reshape((-1, )) hit = 0 total = 0 for i in range(pred.shape[0] / 5): ok = True for j in range(5): k = i * 5 + j if np.argmax(pred[k]) != int(label[k]): ok = False break if ok: hit += 1 total += 1 return 1.0 * hit / total

I notice that the shape of output from model is (batch_size*label_num,softmax_num); and the ground truth label shape is (batch_size,softmax_num). So I just thought the label at [k] after label.T.reshape((-1, )) is not coressponding to np.argmax(pred[k]). I do think it should be:

def Accuracy2(label, pred): # made by me label = label hit = 0 total = 0 for i in range(pred.shape[0] / 5): ok = True for j in range(4): k = i * 4 + j if np.argmax(pred[k]) != int(label[i, j]): ok = False break if ok: hit += 1 total += 1 return 1.0 * hit / total

Am I wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant