-
Notifications
You must be signed in to change notification settings - Fork 26
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
AbstractModel type & neural kernel network #94
AbstractModel type & neural kernel network #94
Conversation
adds examples
merge with previous modification
merge from origin
merge nkn kernel
fix indentation
fix indentation
fix indentation
Codecov Report
@@ Coverage Diff @@
## master #94 +/- ##
==========================================
- Coverage 88.55% 82.27% -6.28%
==========================================
Files 24 27 +3
Lines 690 801 +111
==========================================
+ Hits 611 659 +48
- Misses 79 142 +63
Continue to review full report at Codecov.
|
Hi @willtebbutt , just wondering your idea on this PR, if we are comfortable with these design, I'll move on. |
Hi @HamletWantToCode . Just getting around to looking at this now after being busy last week. Firstly, thanks for putting so much work into this contribution. Before I dive into reviewing specifics, I wonder if you could explain why |
Hi @willtebbutt , thanks for the reply, hope I don't disrupt you. Here is what I think: Since Flux is build for neural network, it's
The newly added
|
No problem at all. I just took longer than I would have liked to take a look at the work, and didn't want to give you the impression I'm not enthusiastic about what you're doing (I'm very excited about it!) Your explanation seems very reasonable to me, and I think that I agree with the overall principle. A couple of initial comments:
|
I totally agree with your idea.
Thanks for pointing this out, I reread my code,
Yes, they currently just return empty tuples, you can run following code to check: eq = EQ() # EQ kernel don't have any parameters
Stheno.child(eq) # will return (), a empty tuple
Stheno.get_iparam(eq) # will return 0-element Array{Union{},1} |
Great!
Ah, yes, I totally believe that's a thing. I would have preferred not to have to implement anything for get_iparam(::EQ) = Union{}[]
child(::EQ) = () It shouldn't be necessary to write this code at all! |
Hi @willtebbutt:
Now you don't need to implement Also add tests to NKN as we discussed in PR #95 . |
@HamletWantToCode what are your plans for this PR now? |
Like our previous discussion, I still think it's better for
I was also working on my thesis these days, and would like to use |
Sorry for the slow response -- I've been trying to figure out how I want things to proceed. On the one hand, I agree that Flux's API isn't completely ideal for Stheno.jl, in particular the need to always make parameters heap-allocated is very frustrating. On the other I'm very reluctant to roll our own interface that's specific to this package because one of the main selling points of the package is its interoperability with other packages in the ecosystem. While I'm sure something could be devised that could be made to work with other packages, it's unclear how straightforwardly this would apply in general. Moreover, On the whole, I think its best that we go with the Flux API because, from a performance perspective, it's not too bad. That being said, there's nothing to stop us creating a couple of types that help us with transforming input variables, but that themselves play nicely with Flux. We could open a separate issue to discuss that.
Fantastic! Do you specifically need the pseudo-point stuff to work? |
Hi @willtebbutt , it took me some time to digest your comment ;) Totally agree with your idea on emphasizing the "interoperability with other packages in the ecosystem", and I think it's also better to determine which package should be included in that ecosystem, this will help us figure out how to modify the current API and make it clear what functionality should be added in the future. Also, there are some questions
Could you explain how this works, because someone told me
I play with
While
Since my dataset isn't that large ( 2K~5K ), I think it's OK to use exact gp. I may use additive GP model and multi-output GP model, and I would like |
let's close this PR for now, we can always come back when we need. |
This isn't correct.
Yeah, this is currently the case. I've been holding off on switching Stheno over to KernelFunctions until it's at a level of maturity that is equivalent to Stheno, and we've settled on an API for KernelFunctions. I suspect a couple of things will wind up being named slightly differently to Stheno's conventions, but I'm anticipating it being broadly similar eventually. |
Overview
This PR contains neural kernel network and additional functionalities, it's an enhanced version of PR #92. While adding neural kernel network, this PR is intended to maintain Stheno's current APIs, and it also gives the 2nd & 3rd point we discussed here a try.
A quick summary of new functionalities:
AbstractModel
: base type for all parametric typesparameters
: function used to extract parameters within a model to a 1D arraydispatch!
: function used to redistribute parameters to the modelextract_gradient
: function used to extracted gradients from theNamedTuple
returned by Zygote.jlLinearLayer
: linear transformation with positive weightsProductLayer
: element-wise kernel multiplicationChain
: chain linear layer and product layer together to build a sum-product networkPrimitive
: kernel containerNeural_Kernel_Network
Usage
example of neural kernel network can be find here.
To be discussed
AbstractModel
: adding this type will introduce a tree structure for our model, makes it easy for us to extract and redistribute the parameters.parameters
&dispatch!
functions are based on it, these two functions facilitate us using both Flux's stochastic optimizer and Optim.jl's traditional optimizer. When dealing with realistic problems, our model may contains a large number of parameters, manually writingunpack
andrepack
function each time may be annoying.All tests passed on my laptop ( macOS, julia 1.3.0 )