-
Notifications
You must be signed in to change notification settings - Fork 653
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
Multi array label Softmax Cross Entropy loss function #10
Comments
@jSaso Our currently API already support multiple input/multiple label/multiple output use case. Here is some quick pointer:
NDList class not only allows users process NDArray by its order, you can actually use named NDArray, so you don't need worry about the order of the inputs. Here is code that handles multiple inputs: https://github.com/awslabs/djl/blob/master/mxnet/mxnet-model-zoo/src/main/java/ai/djl/mxnet/zoo/nlp/qa/BertQATranslator.java#L53-L62 |
Thanks @frankfliu |
@jSaso Could you use the |
I created an example showing how to implement a multi array label softmax cross entropy loss function at https://github.com/awslabs/djl/blob/master/examples/src/main/java/ai/djl/examples/training/TrainCaptcha.java. Please take a look and let me know if there are any further problems or suggestions. |
Co-authored-by: Frank Liu <frankfliu2000@gmail.com>
Description
We want to have multi array labels/prediction. Currently API can handle only one label (first element in NDArray). Obvious examples are Multi digit number recognition, where we can predict multiple digits from provided input. Example of this: https://github.com/eclipse/deeplearning4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/convolution/captcharecognition/MultiDigitNumberRecognition.java
Also there are many cases when we want multiple array labels, especially when dealing with just numbers (outputs) and predictions.
There is small thread about this (python):
https://datascience.stackexchange.com/questions/23614/keras-multiple-softmax-in-last-layer-possible
Documentation for this is very hidden or non existent - the same is with examples. Everyone is using just single array label, multiple classes (out neurons):
[0.2, 0.3, 0.6,...0.12] -> 0.6
We want to have multiple array labels, multiple classes (out neurons):
[0.2, 0.3, 0.6,...0.12] -> 0.6
[0.4, 0.2, 0.7,...0.88] -> 0.88
[0.11, 0.77, 0.55,...0.33] -> 0.77
:
:
Will this change the current api?
Hopefully only new loss function (class) can be implemented, which will calculate multi array labels (Split tensor to parts, then compute softmax separately per part and concatenate tensor parts at end) - SoftmaxCrossEntropyLossMulti.
References
The text was updated successfully, but these errors were encountered: