STOR-i / GaussianProcesses.jl

A Julia package for Gaussian Processes
https://stor-i.github.io/GaussianProcesses.jl/latest/
Other
308 stars 53 forks source link

Fix arbitrary hyperparameters #156

Closed mvsoom closed 4 years ago

mvsoom commented 4 years ago

It would be nice if the optimize! function could fix arbitrary parameters (i.e. not optimize them and use them as givens), rather than fixing groups of parameters with the domean, kern and noise keywords. Maybe these keywords could be extended to take in vectors of Bools?

mvsoom commented 4 years ago

Excuse me, I just realized they can be fixed using the bounds in optimize!. I read over that part in the example notebook.

chris-nemeth commented 4 years ago

Great. Sorry I didn't respond to this sooner. Glad to hear that you solved it!

mvsoom commented 4 years ago

Unfortunately, that doesn't seem to work either. I'm trying to fix the signal σ to one.

K = SEIso(0., 0.)
gp = GPE(X, y, MeanZero(), K, 0.)
optimize!(gp; kernbounds = [(-Inf, 0.), (Inf, 0.)])

Output:

┌ Warning: Initial position cannot be on the boundary of the box. Moving elements to the interior.
│ Element indices affected: [3]
└ @ Optim /home/marnix/.julia/packages/Optim/SFpsz/src/multivariate/solvers/constrained/fminbox.jl:227
ArgumentError: Value and slope at step length = 0 must be finite.

I'm moving on to another solution (smoother constraints using priors, as it should be done anyway) but I thought I'd let you know anyway. Thanks for the great library by the way!

chris-nemeth commented 4 years ago

Your initial thought of using a vector of Bool would probably work if we wanted to extend the domean, kern, etc. args. I don't think this will be a priority at the moment as we're planning to change the structure of the parameters and introduce parameter types. A slightly hacky solution based on what you've already got with kernbounds might be to limit the range to (-0.01,0.01), rather than (0.0,0.0).

maximerischard commented 4 years ago

Hi @mvsoom, it seems that what you're looking for is the FixedKernel, which is poorly documented (sorry!). You can fix parameters within a kernel either by name or by index. Probably easiest to look directly at the source code: https://github.com/STOR-i/GaussianProcesses.jl/blob/master/src/kernels/fixed_kernel.jl

mvsoom commented 4 years ago

That's good to know, thank you for the feedback. And thanks again for the work you put in all of this.