Key Error: model and guide names do not match

I have enclosed the following error description and two images of the model and guide function. I am not understanding what the key error means.

Just to give a background of what I am doing. I have my prior weights drawn from a categorical distribution and my variational posterior is also categorical

i am passing these sampled weights to a neural network for bayesian inference.

runfile(‘C:/Users/SRIKANTH R/.spyder-py3/’, wdir=‘C:/Users/SRIKANTH R/.spyder-py3’)

File “C:\Users\SRIKANTH R\Anaconda3\lib\site-packages\spyder\utils\site\”, line 705, in runfile
execfile(filename, namespace)

File “C:\Users\SRIKANTH R\Anaconda3\lib\site-packages\spyder\utils\site\”, line 102, in execfile
exec(compile(, filename, ‘exec’), namespace)

File “C:/Users/SRIKANTH R/.spyder-py3/”, line 183, in

File “C:/Users/SRIKANTH R/.spyder-py3/”, line 156, in do_inference

File “C:\Users\SRIKANTH R\Anaconda3\lib\site-packages\pyro\infer\”, line 99, in step
loss = self.loss_and_grads(self.model,, *args, **kwargs)

File “C:\Users\SRIKANTH R\Anaconda3\lib\site-packages\pyro\infer\”, line 126, in loss_and_grads
loss_particle, surrogate_loss_particle = self._differentiable_loss_particle(model_trace, guide_trace)

File “C:\Users\SRIKANTH R\Anaconda3\lib\site-packages\pyro\infer\”, line 95, in _differentiable_loss_particle
log_r = _compute_log_r(model_trace, guide_trace)

File “C:\Users\SRIKANTH R\Anaconda3\lib\site-packages\pyro\infer\”, line 21, in _compute_log_r
log_r_term = log_r_term - guide_trace.nodes[name][“log_prob”]

File “C:\Users\SRIKANTH R\Anaconda3\lib\site-packages\networkx\classes\”, line 178, in getitem
return self._nodes[n]

KeyError: ‘cn1_prior_dist_sample’

looks like in your model you called your sample cn1_prior_dist_sample but cn1_dist_sample in your guide. you should set pyro.enable_validation(True) to catch these errors for you.

Thanks a lot. Will try it out