numpy/numpy-tutorials

Deep learning on MNIST, visualize results, metrics error

KirahviF opened this issue · 1 comments

The line

y_test_accuracy = [
    store_training_accurate_pred[i] / float(len(training_images))
    for i in range(len(store_training_accurate_pred))
]

seems to be wrong, it should be:

y_test_accuracy = [
    store_test_accurate_pred[i] / float(len(test_images))
    for i in range(len(store_test_accurate_pred))
]

It's easy to miss because of the same length of training_images and test_images. That's why I suggest change numbers training_sample & test_sample from 1000 & 1000 to 2000 @ 1000 for example.
Also I don't understand why convert integer to float here, but maybe it's because of my poor knowledge...

Thanks for reporting @KirahviF - you are correct, very nice catch! This whole code block is difficult to interpret with so many new names being created - there's a lot here that can be improved IMO, but the most important part is to fix the mistake.

That's why I suggest change numbers training_sample & test_sample from 1000 & 1000 to 2000 @ 1000 for example.

Good idea - would you be interested in testing this out and perhaps submitting a PR?

Also I don't understand why convert integer to float here, but maybe it's because of my poor knowledge...

This is another good observation - I suspect this is a holdover pattern from pre-Python3 before Python switched to the / == truediv, // == floordiv operators. It's not a "bug" per se, but definitely has a code smell and should also be improved.