HITS-AIN / PINK

Parallelized rotation and flipping INvariant Kohonen maps
GNU General Public License v3.0
21 stars 11 forks source link

Mapping broken in CPU version #59

Closed avantyghem closed 4 years ago

avantyghem commented 4 years ago

When mapping an image file through a SOM file, Pink functions as expected when run on a GPU. However, with the --cuda-off flag the distance array is zero in every element. I encounter this for Git revisions 6ebe6a6 and feac562.

BerndDoser commented 4 years ago

Thanks for pointing out. I will try to reproduce your issue.

avantyghem commented 4 years ago

I think this problem arises when the euclidean-distance-shape used to map differs from that used to train, but only in CPU-mode. I was using a SOM that was trained on the default shape, but using the circular shape when mapping.

BerndDoser commented 4 years ago

Can you please give me your parameters of the training and mapping? The easiest way will be to copy the std output.

avantyghem commented 4 years ago

I have been testing this with two SOMs. One trained using the default euclidean-distance-shape (see default_som_training.log) and the other using the circular shape (see circ_som_training.log).

Here are the mappings that I've tested. Each uses the same image file, and I've experimented with different SOMs and different euc-dist-shape in the mapping process. circ_map_circ_som.log circ_map_default_som.log default_map_default_som.log

My previous guess was wrong -- it's not an issue with mismatching shapes. My output map binary is all zero whenever I map it with --euclidean-distance-shape circular. Whether I use default or circular for this when training doesn't matter. Again, this is only when using --cuda-off.

Let me know if you need anything else.

BerndDoser commented 4 years ago

I can't reproduce it using 2-dim images and following settings:

''' Data file = /home/bernd/data/pink/all_shapes_shuffled/images_scaled_v2.bin Result file = map.bin SOM file = som.bin Number of data entries = 4000 Data dimension = 64 x 64 SOM dimension (width x height x depth) = 10x10x1 SOM size = 100 Number of iterations = 1 Neuron dimension = 91x91 Euclidean distance dimension = 45 Data type for euclidean distance calculation = uint8 Shape of euclidean distance region = quadratic Maximal number of progress information prints = 10 Intermediate storage of SOM = off Layout = cartesian Initialization type = file_init SOM initialization file = som.bin Interpolation type = bilinear Seed = 1234 Number of rotations = 360 Use mirrored image = 1 Number of CPU threads = 8 Use CUDA = 0 Store best rotation and flipping parameters = 1 Best rotation and flipping parameter filename = rot-flip.bin '''

The resulting heatmap of the first image looks ok:

I will try it now for multi-channel images.

avantyghem commented 4 years ago

That mapping is done with Shape of euclidean distance region = quadratic, which works for me. What do you get if you include --euclidean-distance-shape circular?

BerndDoser commented 4 years ago

Thanks @avantyghem. Now I have it. There was a wrong index in CircularEuclideanDistanceFunctor<CartesianLayout<3>> for the CPU path. I have tested a very small test-set with:

''' create_test_image.py --number-of-images 2 --width 4 --height 4 --depth 2 --fill-with diag Pink --train data.bin som.bin --som-width 2 --som-height 2 --num-iter 1 --cuda-off --flip-off --numrot 1 --euclidean-distance-shape circular Pink --map data.bin map.bin som.bin --som-width 2 --som-height 2 --cuda-off --flip-off --numrot 1 --euclidean-distance-shape circular show_heatmap.py map.bin ''' resulting in the heatmap: