naturomics / CapsNet-Tensorflow

A Tensorflow implementation of CapsNet(Capsules Net) in paper Dynamic Routing Between Capsules
Apache License 2.0
3.8k stars 1.17k forks source link

Getting test prediction labels per image #57

Open Nicholas-Autio-Mitchell opened 6 years ago

Nicholas-Autio-Mitchell commented 6 years ago

First of all, thank you for this wonderful implementation. Not only does it work like a charm, I am learning a lot about how to use Tensorflow effectively :+1:

I trained the code with all default on the MNIST dataset, which returned an accuracy of 99.49 %. That great!

I am now trying to classify some of my own handwritten MNIST digits. I have created 15,000 samples, black and white digits, with the same dimensions as MNIST. I created a small function to feed my data into main.py, and eventually got things working.

My problem is that I get a test-accuracy of ~9%, which equates to random guessing on the 10 classes!

For this reason, I would like to get the predicted labels back for each of the images, so that I can try to debug. Is there an easy way to do this? Could you please provide any hints?

Any help would be much appreciated!

naturomics commented 6 years ago

I created a tool to visualize the predicted labels. you can use it directly.

The idea of that tool is get all the predicted labels(10 labels) for each sample, then we get an matrix with shape [num_sample, num_labels]. For each label, plot the point (sample_id, probability) in the R^2 coordinate. Finally you will get a cool picture, see the gif example here.

The tool can be found here.

What you need to do in the code is save the predicted labels/activation probability, and just plot it. See my CapsLayer repo for details.