Giter Site home page Giter Site logo

Comments (4)

zachgk avatar zachgk commented on August 17, 2024 1

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.

from djl.

frankfliu avatar frankfliu commented on August 17, 2024

@jSaso
Thanks very much for reaching out to us.

Our currently API already support multiple input/multiple label/multiple output use case.
I agree it's not obvious by just looking at the API. And we don't have examples to show case this usage. We will add examples/document to make it clear.

Here is some quick pointer:

  1. Loss API uses NDList, NDList is a list of NDArray, not a single NDArray, so it can handle multiple data and labels.
  2. Batch API uses NDList type for data and labels, it's not NDArray, NDList can take multiple data and multiple labels.
  3. Translator, when pre-processing and post processing data, you can see its also using NDList, which allows user handle multiple input and outputs.

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

from djl.

jSaso avatar jSaso commented on August 17, 2024

Thanks @frankfliu
I saw that API uses NDList. Thats why I thoot that multi array labels - multi class are supported. This is not the case in current API.
It would be nice to to have this supported - implement softmax loss function which support not just single label array, but multiple labels array.
Currently I don't have time to open PR about this feature, but it would be nice to have that feature in DJL API.

from djl.

zachgk avatar zachgk commented on August 17, 2024

@jSaso Could you use the CompositeLoss to combine multiple SoftmaxCrossEntropyLosses together?

from djl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.