Comments (12)
A quick fix might be to store a dummy array of length N_obs
(or two) in the GP struct to avoid having to frequently reallocate arrays of the same size.
from abstractgps.jl.
In places like the above code sample. I'm not quite sure how well Julia can optimise such code, I guess this might be another argument for creating some benchmarks. I will try to upload some BayOpt-related ones soonish.
from abstractgps.jl.
Agreed. My personal preference would be to get people to utilise / further develop things like AutoPreallocation, rather than having to maintain two implementations of basically the same functionality.
from abstractgps.jl.
Thinking about it, AutoPreallocation might work moderately nicely in our case as-is, and get rid of a lot of memory use.
from abstractgps.jl.
Sounds like an interesting idea, I haven't heard of this one before! In the meanwhile I'll have a look and see if we can reduce allocations manually.
from abstractgps.jl.
On a first glance it does seem like doing this manually will require a lot of auxiliary functions, eg.
function Statistics.mean!(out::AbstractVector, f::PosteriorGP, x::AbstractVector)
mean!(out, f.prior, x)
mul!(out, cov(f.prior, x, f.data.x), f.data.α, true, true) # Still allocates for cov
end
or manual matrix operations (good idea?). Given that a lot of these functions are multiply nested would AutoPreallocation.jl handle them gracefully?
from abstractgps.jl.
My experience with this in SciML is that currently the only proper way to solve this explicitly (i.e., without AutoPreallocation) is to have dedicated types and caches for in-place and out-of-place operations. Also it becomes very tricky very quickly to ensure that the matrices, vectors etc. are initialized with the correct types and a lot of fine-tuning and special casing is needed. ArrayInterface was designed to help with the special casing and introduces some traits for arrays (e.g., to query mutability).
from abstractgps.jl.
The main computation one has to do is of the form K_xx * K_xy
for a single input location y
, surely one could add a simple vector or two to the struct? As these are only intermediate results a Vector
might even work (I think)...
from abstractgps.jl.
The main problem is to guarantee that 1) you can actually mutate stuff and 2) that the element types are correct. In particular, 2) is quite tricky - e.g., what happens if some of the inputs or new data are dual numbers or if you use number types with units? This caused many bugs in e.g. OrdinaryDiffEq since it is quite difficult. And I doubt that this can be solved generally if e.g. posterior(::PosteriorGP, data)
does not restrict the type of data
.
Additionally, if you use static arrays usually you don't want to allocate any Vector
s and avoid any in-place operations.
from abstractgps.jl.
I see your point. I'll try to experiment with AutoPreallocation in this case.
from abstractgps.jl.
Another approach would be to avoid vectorisation and write explicit loops using k(x_i, y)
instead. Any thoughts?
from abstractgps.jl.
Where exactly? It's difficult to say without concrete example but in general I don't think it's a good idea to rewrite large parts with explicit loops since then you might miss optimizations such as BLAS calls or for special structures of vectors, matrices, and/or kernels.
from abstractgps.jl.
Related Issues (20)
- VFE/DTC's internal implementation needs a reference
- AD tests
- VFE/DTC should be moved to ApproximateGPs.jl HOT 3
- Should LatentFiniteGP contain the noise?
- Documentation build is ~ 55 min HOT 3
- Cross tests for SurrogateAbstractGPs
- 1D regression inconsistent with other package HOT 3
- Kernel for multidimensional output HOT 3
- ERROR: MethodError: no method matching Int64(::Irrational{:log2π}) HOT 7
- Zygote errors with parameterized mean functions and multidimensional input HOT 10
- Tidy up example 0
- Latency HOT 6
- Zygote v0.6.56 breaks tests HOT 6
- Stabilize `MeanFunction` API HOT 2
- An abstraction for the realization of a GP HOT 11
- Feature parity with GaussianProcesses.jl
- Hyperparameter optimization & maintanance HOT 7
- Noise parameter `Sigma` can't be recovered from `PosteriorGPs` HOT 5
- Log-likelihood is lower after fitting the process? HOT 5
- AbstractGP shares array data - impossible to add new points to grid (bayesian optimisation) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abstractgps.jl.