We have made some major changes to the torch.distributions API, and would like to make this available in Pyro in its full generality. However, the current Pyro shape semantics are incompatible with this new API.
Some of these incompatibilities are as follows:
- The
batch and sample dimensions in Pyro are conflated, which makes it confusing for the user to determine the shape of the distribution parameters to be supplied, i.e. it is common to provide identical distribution parameters only to impose a shape on the sample.
- Any batching (i.e.
sample dimensions) is restricted to a single dimension, and does not support arbitrary shaped sample sizes.
- In the absence of scalar support,
batch_log_pdf upcasts the resulting score by appending an additional (1,) rightmost dimension. In the case of PyTorch, we have tried to localize this behavior to only upcast when any dimension reduction results in a 0 sized tensor. This makes the migration to torch.Scalar simpler.
By the next PyTorch release, we would like to have this rich and updated API available to Pyro. @fritzo and I decided that it will simplify the transition if Pyro's dev branch only tries to maintain compatibility with PyTorch's master instead of the release version which it does now (refer to Phase 1.5).
The transition plan is as follows:
Phase 1 - Changes in PyTorch:
Phase 1.5 - Infra / internal changes to help with migration:
Can be done simultaneously with Phase 1.
Phase 2 - Internal change to Distributions API:
We have made some major changes to the
torch.distributionsAPI, and would like to make this available in Pyro in its full generality. However, the current Pyro shape semantics are incompatible with this new API.Some of these incompatibilities are as follows:
batchandsampledimensions in Pyro are conflated, which makes it confusing for the user to determine the shape of the distribution parameters to be supplied, i.e. it is common to provide identical distribution parameters only to impose a shape on thesample.sampledimensions) is restricted to a single dimension, and does not support arbitrary shaped sample sizes.batch_log_pdfupcasts the resulting score by appending an additional(1,)rightmost dimension. In the case of PyTorch, we have tried to localize this behavior to only upcast when any dimension reduction results in a 0 sized tensor. This makes the migration totorch.Scalarsimpler.By the next PyTorch release, we would like to have this rich and updated API available to Pyro. @fritzo and I decided that it will simplify the transition if Pyro's
devbranch only tries to maintain compatibility withPyTorch'smaster instead of thereleaseversion which it does now (refer to Phase 1.5).The transition plan is as follows:
Phase 1 - Changes in PyTorch:
pyro.distributionsin Pyro which preserve our current shape semantics.Phase 1.5 - Infra / internal changes to help with migration:
Can be done simultaneously with Phase 1.
Phase 2 - Internal change to Distributions API:
Move the
.__init__(batch_size=None)argument to.sample(sample_shape=torch.Size())Update the wrappers to expose the full generality of the
torch.distributionsAPI. Resolve incompatibilities in inference algorithms likeTrace_ELBOandTraceGraph_ELBO.Incorporate arbitrary batch dimensions in
iarangeSupport irange/iarange nested inside iarange #370Update all examples and tutorials to use the new API. - Fix tutorials to accommodate new batching semantics #726