Open sebascuri opened 4 years ago
@sebascuri Given that the existence of __add__
and __mul__
is already a deviation from the PyTorch base clase (which doesn't support any form of + or - on distributions), I think this could be reasonable. Right now, since A + B semantically means "treat A and B as random variables and add them," being able to also do s*A + m makes sense to me.
In my opinion, feel free to open a PR since you mention you're willing to!
🚀 Feature Request
Currently, MultivariateNormal has implemented add and mul methods with either (i) another multivariate normal , or (ii) floats/ints. It would be useful to accept tensors (with compatible dimensions).
Motivation
Say I have MVN with mean [3, 2] and some covariance. Say I want to shift it by [-1, 2]. Currently, I can only do so by creating a new MVN object as the add method forces me to create a new MVN object with some pos. def. covariance matrix.
Say I have a Multitask MVN, with some mean per task and covariance per task. Say I would like to shift each task and rescale each task by different values. Currently, this is not supported.
This is useful for multi-output regression, where each output could have potentially different means and scales. For training, the input/outputs are normalized, but during prediction, these should be re-scaled.
Pitch
Describe the solution you'd like I'd like a solution that either: (i) for each task of the Multitask MVN, returns me a MVN that I could shift and scale. (This could be useful by itself).
(ii) for a Multitask MVN, it accepts a tensor both in the add and mul methods
Describe alternatives you've considered
Currently my code looks like this:
I think something like
should work
Are you willing to open a pull request? (We LOVE contributions!!!) Yes