Are the two ways of training SVI models equivalent?
The first one, as is used in pyro tutorial:
# mini-batch logic defined in the model function with pyro.plate svi = pyro.infer.SVI(model, guide, optim, loss = pyro.infer.Trace_ELBO()) for i in range(num_iters): svi.step(X, y)
The second one, which is more common in pytorch:
from torch.utils.data import TensorDataset, DataLoader dataset = TensorDataset(X, y) loader = DataLoader(dataset, batch_size = batch_size, shuffle = True) # No mini-batch logic in model svi = pyro.infer.SVI(model, guide, optim, loss = pyro.infer.Trace_ELBO()) for epoch in range(num_epoch): for bx, by in loader: svi.step(bx, by)