Clarification reagrding svi.step


I am doing bayesian inference in Pyro. I have defined the model and the guide functions inside a class.

consider the following:

class bayesian_inf(object):

… some lines of code
def model(self,images,labels):
… some lines of code

def guide(self,images,labels):
…some lines of code

def do_inference(self):
… some lines of code


… some lines of code


My doubt is that does the svi.step function provide images and labels(ex: for each mini-batch of examples) to the model and guide function automatically behind the scenes? or do I need to send every mini batch of data to do_inference function


svi calls model and guide with the args passed to it:

def model(data):

svi.step(data)  # data will be passed to the model above

if you want to do minibatching, you have to do it outside of svi:

def model(images, labels):

def guide(images, labels):

for i in range(epochs):
    minibatch_images = ...
    minibatch_labels = ...
    svi = SVI(model, guide, optim, loss)
    svi.step(minibatch_images, minibatch_labels)


Great. Thanks a lot