-
I'm trying to use a single task GP model to find optimal values of some independent inputs based on their ability to maximize some output. Using domain knowledge I'm able to losslessly compute some additional features that I know will yield stronger model signal than just the raw input values. There may be N features constructed from M inputs such that N > M. I've been trying to add this featurization layer at the top level of a SingleTaskGP model. I've tried several approaches, but I can't seem to get any to optimize over the raw top level inputs rather than over the GP model feature space. I've tried to reproduce a simple example below. Here I'm defining two inputs X1 and X2, then adding a third "feature" defined as X3 = X1 * X2. When I add this as an input transform, the optimizer expects 3 bounds, presumably because it wants to optimize over the feature space rather than the raw inputs. I've tried subclassing SingleTaskGP and augmenting its forward pass method as well, but to no avail. Something I should add is that the featurization is not readily invertible, so I can't just convert candidates from model feature space back to the original input dimensions. Any suggestions would be greatly appreciated. Thank you!
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You almost got it right. The
Pro tip: Since BoTorch and GPyTorch make heavy use of batching and in principle work with arbitrary batch dimensions, it is usually best to index "from the back". |
Beta Was this translation helpful? Give feedback.
You almost got it right. The
@t_batch_transform
that is applied inProbabilityOfImprovement
here: https://github.com/pytorch/botorch/blob/main/botorch/acquisition/analytic.py#L162 and in most other acquisition functions means that the tensor that is seem by theforward
methods of the transforms is at least three-dimensional / has at least one batch dimension. That means that your indexing is off. If you change your method as follows this works as you intended:Pro tip: Since BoTorch and GPyTorch make heavy use of batching and in principle wor…