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

[api] add NDArray gammaln and sample distribution function support. #1990

Merged
merged 4 commits into from
Sep 9, 2022

Conversation

Carkham
Copy link
Contributor

@Carkham Carkham commented Sep 4, 2022

Description

This PR implements several function.

gammaln is the same as the log gamma function of torch.lgamma, mxnet.nd.gammaln.
It is used in the distributions package of torch and mxnet to calculate the probability density at the value, and this result can be used for the loss function calculation of the predicting probability distribution model. This is the training process.

sample is the same as the sample distribution function of torch.distributions.Distribution.sample, mxnet.nd.sample_xxx
It is used in the ditributions package to draw samples from corresponding distribution. The samples serve as inference outputs of the model and can be converted to Forecast through TimeSeriesTranslator. This is the inference process.

I'm not sure which java class the sample_xxx function should be placed in. I put them in the NDManager for the time being, because these functions look similar to NDManager.random functions.

@codecov-commenter
Copy link

codecov-commenter commented Sep 4, 2022

Codecov Report

Merging #1990 (9b0d039) into master (bb5073f) will decrease coverage by 2.19%.
The diff coverage is 67.99%.

@@             Coverage Diff              @@
##             master    #1990      +/-   ##
============================================
- Coverage     72.08%   69.89%   -2.20%     
- Complexity     5126     5929     +803     
============================================
  Files           473      586     +113     
  Lines         21970    26244    +4274     
  Branches       2351     2846     +495     
============================================
+ Hits          15838    18344    +2506     
- Misses         4925     6520    +1595     
- Partials       1207     1380     +173     
Impacted Files Coverage Δ
api/src/main/java/ai/djl/modality/cv/Image.java 69.23% <ø> (-4.11%) ⬇️
...rc/main/java/ai/djl/modality/cv/MultiBoxPrior.java 76.00% <ø> (ø)
...rc/main/java/ai/djl/modality/cv/output/Joints.java 71.42% <ø> (ø)
.../main/java/ai/djl/modality/cv/output/Landmark.java 100.00% <ø> (ø)
...main/java/ai/djl/modality/cv/output/Rectangle.java 72.41% <0.00%> (ø)
...i/djl/modality/cv/translator/BigGANTranslator.java 21.42% <0.00%> (-5.24%) ⬇️
...odality/cv/translator/BigGANTranslatorFactory.java 33.33% <0.00%> (+8.33%) ⬆️
.../cv/translator/InstanceSegmentationTranslator.java 0.00% <0.00%> (-86.59%) ⬇️
...nslator/InstanceSegmentationTranslatorFactory.java 7.14% <0.00%> (-11.04%) ⬇️
.../cv/translator/SemanticSegmentationTranslator.java 0.00% <0.00%> (ø)
... and 509 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Carkham Carkham changed the title feature: add gammaln function support. [api] add NDArray gammaln function support. Sep 5, 2022
@Carkham Carkham marked this pull request as draft September 6, 2022 12:58
@Carkham Carkham marked this pull request as ready for review September 7, 2022 14:28
@Carkham Carkham changed the title [api] add NDArray gammaln function support. [api] add NDArray gammaln and sample distribution function support. Sep 7, 2022
@Carkham Carkham marked this pull request as draft September 8, 2022 03:43
@Carkham Carkham marked this pull request as ready for review September 8, 2022 14:43
@KexinFeng KexinFeng self-requested a review September 8, 2022 17:32
@KexinFeng KexinFeng merged commit aa5c1a2 into deepjavalibrary:master Sep 9, 2022
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.

3 participants