Improper Empirical still saves simulations
In #1700 the simulation cache should have been removed from the ImproperEmpirical prior, but its still there because it call super().__init__(values, log_weights=log_weights) and subclasses Empirical. Given that sample now raises an error these are not used at all and should be removed (i.e. by not using inheriting from Empirical.
Furthermore there is a bug in to method i.e. see below. This surfaced in #1793 .
class ImproperEmpirical(Empirical):
"""
Wrapper around pyro's `Emprirical` distribution that returns constant `log_prob()`.
This class is used in SNPE when no prior is passed. Having a constant
log-probability will lead to no samples being rejected during rejection-sampling.
The default behavior of `pyro.distributions.Empirical` is that it returns `-inf`
for any value that does not **exactly** match one of the samples passed at
initialization. Thus, all posterior samples would be rejected for not fitting this
criterion.
"""
def __init__(self, values: Tensor, log_weights: Optional[Tensor] = None):
super().__init__(values, log_weights=log_weights)
# Warn if extremely large to inform about memory/serialization cost.
self._mean = self._compute_mean(values, log_weights)
self._variance = self._compute_variance(values, log_weights)
...
...
...
def to(self, device: Union[str, torch.device]) -> None:
"""
Move the distribution to a different device.
Args:
device: The device to move the distribution to.
Returns:
The distribution on the specified device.
"""
self._mean = self._mean.to(device)
self._variance = self._variance.to(device)
#super().to(device) TODO: This needs to be removed as neither Distirbution nor Empirical implement it.
Improper Empirical still saves simulations
In #1700 the simulation cache should have been removed from the
ImproperEmpiricalprior, but its still there because it callsuper().__init__(values, log_weights=log_weights)and subclassesEmpirical. Given thatsamplenow raises an error these are not used at all and should be removed (i.e. by not using inheriting fromEmpirical.Furthermore there is a bug in
tomethod i.e. see below. This surfaced in #1793 .