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

Quession about loss calculation #12

Open
mrgloom opened this Issue Aug 4, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@mrgloom
Copy link

commented Aug 4, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.