-
Notifications
You must be signed in to change notification settings - Fork 72
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
Serialization and representation GP + Small fixes #64
Conversation
Merging master onto Serialization branch
Codecov Report
@@ Coverage Diff @@
## master #64 +/- ##
==========================================
+ Coverage 46.96% 47.49% +0.52%
==========================================
Files 37 37
Lines 5636 5740 +104
==========================================
+ Hits 2647 2726 +79
- Misses 2989 3014 +25
Continue to review full report at Codecov.
|
Regarding the string to kernel logic, you may be able to refactor the function to use Unclear if this would be better though 🤷♂ |
(As this is mostly regarding the serialization of environments, this might not be the best place for the discussion) |
I've been using an encoder that I found online which is included in util.py to handle converting numpy arrays to JSON.
Thanks for looking closely at the methods! What would the |
I see, I didn't see the Whoops that was suppose to be current_module = sys.modules[__name__] # Gets the current module
if hasattr(current_module, "two_body"):
func = getattr(current_module, "two_body") |
…com/mir-group/flare into Serialization_and_representation_GP
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.
Looks good. Also used this as an opportunity to address some of the linting issues that have been hanging around gp for awhile.
# self_kern = self.kernel(x_t, x_t, self.bodies, d, d, self.hyps, | ||
# self.cutoffs) | ||
# pred_var = self_kern - np.matmul(v_vec, v_vec) | ||
|
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.
Nice, these lines needed to go.
self.like = like | ||
self.like_grad = like_grad | ||
self.likelihood = like | ||
self.likelihood_gradient = like_grad |
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.
Good catch, not sure why there were multiple versions of the likelihood.
for hyp, label in zip(self.hyps, self.hyp_labels): | ||
thestr += "{}: {}\n".format(label, hyp) | ||
|
||
return thestr |
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.
Slick.
Thanks for taking the time to look through and provide feedback! |
Introduces a serialization method for GPs (to_ and from_dict methods) and a representation (str) method. Introduced a new string-to-kernel method in kernels.py to facilitate the from_dict method. The serialization is unit tested. Fixed a few style errors in other parts of the code. A method in gp.py sets a 'self.like' attribute and others set
self.likelihood
. This is also now corrected towardsself.likelihood
.