def model(self, xs, ys=None): # register this pytorch module and all of its sub-modules with pyro pyro.module("ss_vae", self) # ME: Replace as：pyro.module("ss_vae",self.decoder*)? .... def guide(self, xs, ys=None): # inform Pyro that the variables in the batch of xs, ys are conditionally independent with pyro.plate("data"): # ME: Insert: pyro.module("ss_vae", self.encoder_z)? def model_classify(self, xs, ys=None): # register all pytorch (sub)modules with pyro pyro.module("ss_vae", self) # ME: Replace as: pyro.module("ss_vae", self.encoder_y)? with pyro.plate("data"): def guide_classify(self, xs, ys=None): """ dummy guide function to accompany model_classify in inference """ pass
Can the above code for registering modules in SSVAE be changed to the code in my comment (With ‘ME’ symbol mark)?
In fact, I don’t quite understand what the specific usage of Pyro’s registered neural network to Pyro’s parameter storage(i.e. How to use the pyro.module function ). I thought that whether it is a model or a guide, if it uses nn.module ‘A’, register the nn.module ‘A’. But after I saw the SSVAE code, I completely confused myself. The model function used the decoder, but registered the ‘self’. Does the ‘self’ contain all the nn.modules of the SSVAE class, and if so, So why does model_classify have to register more than one self?