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

Adding one hot operator #684

Merged
merged 4 commits into from
Feb 24, 2021
Merged

Conversation

markbookk
Copy link
Contributor

Description

Adding the one hot operator. This is similar to https://mxnet.apache.org/versions/1.6/api/r/docs/api/mx.nd.one.hot.html

  • Implemented using MXNet and Tensorflow engine.

@codecov-io
Copy link

codecov-io commented Feb 23, 2021

Codecov Report

Merging #684 (58775d5) into master (5b28382) will increase coverage by 0.05%.
The diff coverage is 70.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #684      +/-   ##
============================================
+ Coverage     68.53%   68.59%   +0.05%     
- Complexity     3928     3932       +4     
============================================
  Files           461      461              
  Lines         18220    18222       +2     
  Branches       1963     1963              
============================================
+ Hits          12487    12499      +12     
+ Misses         4716     4706      -10     
  Partials       1017     1017              
Impacted Files Coverage Δ Complexity Δ
...i/src/main/java/ai/djl/ndarray/NDArrayAdapter.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...jl/nn/transformer/BertMaskedLanguageModelLoss.java 17.85% <0.00%> (ø) 1.00 <0.00> (ø)
...va/ai/djl/nn/transformer/BertNextSentenceLoss.java 18.18% <0.00%> (ø) 1.00 <0.00> (ø)
...rc/main/java/ai/djl/nn/transformer/MissingOps.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
api/src/main/java/ai/djl/ndarray/NDArray.java 74.25% <100.00%> (+0.15%) 89.00 <1.00> (+1.00)
...e/src/main/java/ai/djl/mxnet/engine/MxNDArray.java 86.43% <100.00%> (+0.14%) 208.00 <1.00> (+1.00)
api/src/main/java/ai/djl/repository/Artifact.java 89.65% <0.00%> (-1.73%) 36.00% <0.00%> (-1.00%)
.../ai/djl/serving/http/ManagementRequestHandler.java 92.92% <0.00%> (+1.76%) 25.00% <0.00%> (+1.00%)
api/src/main/java/ai/djl/ndarray/NDManager.java 61.65% <0.00%> (+3.75%) 63.00% <0.00%> (+2.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b28382...58775d5. Read the comment docs.

* @param dataType dataType of the output.
* @return one-hot encoding of this {@code NDArray}
*/
NDArray oneHot(int depth, float onValue, float offValue, DataType dataType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this operator commonly used in the mathmatical operations? Or it is jusr for BERT model?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is often used to convert categorical value tokens to a more expressive feature vector, not just for BERT model. Check this and this for an example.

@zachgk zachgk merged commit 17609cb into deepjavalibrary:master Feb 24, 2021
Lokiiiiii pushed a commit to Lokiiiiii/djl that referenced this pull request Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants