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
Addition of Normal Distribution to ANN module #2382
Conversation
@@ -127,4 +128,40 @@ BOOST_AUTO_TEST_CASE(JacobianBernoulliDistributionLogisticTest) | |||
} | |||
} | |||
|
|||
/** | |||
* Normal Distribution module test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we run the Jacobian tests for the normal distribution as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes.. definitely! I've made the changes.. pls have a look
127a61c
to
12b68e7
Compare
closed and reopened PR to re-trigger azure pipelines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @nishantkr18, Thanks for working on this. I have left some minor style comments.
Other than that, I have more of a question which is related to this comment here in #1730.
Do you think that maybe we should update this PR and Bernoulli distribution in another PR and remove that section. Maybe @zoq could provide some input on this one. The only problem that I think that would be there is that a user would have to change the include
statement. Maybe I missed something.
Kindly Let me know what you think.
Thanks for the contribution!
* Normal distribution is a function which accepts a mean and a standard deviation | ||
* term and creates a probablity distribution out of it. | ||
*/ | ||
template <typename DataType = arma::mat> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @nishantkr18, Could also please add a template parameter description. Thanks.
/** | ||
* Return the mean. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @nishantkr18, For single line comments, do you mind using //
to comment. Thanks a lot!
const DataType& Mean() const { return mean; } | ||
|
||
/** | ||
* Return a modifiable copy of the mean. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Return a modifiable copy of the mean. | |
//! Modify the mean. |
/** | ||
* Return the standard deviation. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* Return the standard deviation. | |
*/ | |
//! Get the standard deviation. |
{ | ||
// We just need to serialize each of the members. | ||
ar & BOOST_SERIALIZATION_NVP(mean); | ||
ar & BOOST_SERIALIZATION_NVP(sigma); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry, it's a picky comment, Do you mind shifting this to the implementation file. Most of the code base follows that. Thanks a lot!
Thanks for those, I'll get them sorted. 👍
Yeah, that sounds like a plan. Again I'm waiting for @zoq or @rcurtin 's reviews. |
Sure, I am fine with that. Maybe after this gets merged, we can open an issue to discuss the same, provided it needs discussing. |
Yeah sure 👍 , sorry for the two commits, forgot to add description in the first one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No further comments from my side, thanks for putting this together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second approval provided automatically after 24 hours. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't have any comments, could you add to HISTORY.MD as well before we merge?
Done 👍 |
Thanks again for the contribution! |
Hey!
The implementation of Normal Distribution in #1912 had a small bug in the
LogProbablity()
function. Also, the backward pass and tests for the class was not present.This is an attempt to complete the work, as normal distribution is of use in many places, especially for continuous action space environments in RL module.
For the tests, I have taken 4 random values of
mean
,sigma
andx
to produce corresponding LogProbabilites and gradients, and compared it with pytorch's implementation.I use this snippet to get the
prob
,dmu
anddsigma
.Please have a look and share your thoughts :)