keras-segnet
keras-segnet copied to clipboard
Quession about loss calculation
Seem in the last layers you reshape all to [2,65536] (assuming this is row x col) and 256*256 is 65536, so it's just image with 2 'channels' (assuming background/foreground) reshaped to flat vector. So in general case it will be [n_classes, h*w]. And than softmax is putted on top.
https://github.com/imlab-uiip/keras-segnet/blob/master/SegNet.py#L19
https://github.com/imlab-uiip/keras-segnet/blob/master/model_5l.json#L1266
Also here you use categorical_crossentropy loss.
https://github.com/imlab-uiip/keras-segnet/blob/master/SegNet.py#L108
My confusion is how softmax is applied and how loss is computed, as I understand it should be like:
compute softmax for each [2,i] (and not to [i,65536]) subvector separately of matrix and loss should be computed for each pixel, so as I understand Keras just do it all in some vectorized form?
So what is the rules to pass matrix/tensor to softmax+categorical_crossentropy? what shape shoul it be? row represent dimensions and cols represent pixels?
Documentation is not rich about this topics:
https://keras.io/activations/#softmax
https://keras.io/losses/#categorical_crossentropy
BTW what is profit of store model as .json ? I find this solution less readable.