-
Hello! I am struggling to figure out the best way to create a custom (non-deterministic) model in BoTorch without using a GP from GPyTorch. According to the docs, the base model API requires a Posterior method, which returns a Posterior object. Does this have to be a GPyTorch posterior? As a simple example, I'd like to build a FF network with dropout, from which I'd sample N times to generate a distribution over X. What would be the best way to wrap that in a posterior so that it is compatible with a BoTorch custom model? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Hi @kstone40, a GPytorch posterior is not required. The steps would be to 1) implement a botorch/botorch/posteriors/posterior.py Line 22 in 0d66aa0 rsample (botorch/botorch/posteriors/posterior.py Line 55 in 0d66aa0 Model subclass (e.g. DropoutModel ), construct and return the DropoutPosterior object in the DropoutModel.posterior method. Does that make sense?
|
Beta Was this translation helpful? Give feedback.
-
Hi @Balandat , Thanks for following up! I have been traveling lately myself, so I'm also getting back to this late. My implementation is actually in a recently published repository here: https://github.com/MSDLLCpapers/obsidian/blob/main/obsidian/surrogates/custom_torch.py Since my posterior method accepts X.shape[1] > 1, I believe that q>1 would mean that I am technically evaluating the joint distribution. However, I believe they will be independent anyway based on my understanding of the monte-carlo dropout NN method. I think based on this, I should always enforce optim_sequential=True. Anyway, maybe I am making an improper assumption. I though that for q>1 for custom models, BoTorch automatically would calculate fantasy models when optim_sequential=True. But even when I toggle this, I end up with identical experiments. If, separately, I fit a fantasy model and re-optimize, I get a different result. Do I need to manage this myself in my custom model implementation? |
Beta Was this translation helpful? Give feedback.
Yeah that's the idea. More is better for accuracy, you ofc need to trade this off with compute / memory.
The way
rsample
is implemented is that it can generate repeated draws from the finite samples, see the logic here.