Raise NotImplementedError without any information

I implemented a hmm model for my own model by referencing the HMM tutorial, when I use the AutoDelta guide and the TraceEnumElbo, got an error without any information.

I noticed that there were some error information for debugging in some other posts, but there is no information in my case.

Please find the output below:

Traceback (most recent call last):
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 85, in forward
raise NotImplementedError
NotImplementedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/contrib/autoguide/init.py”, line 277, in call
self._setup_prototype(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/contrib/autoguide/init.py”, line 106, in _setup_prototype
self.prototype_trace = poutine.block(poutine.trace(self.model).get_trace)(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 169, in get_trace
self(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 153, in call
traceback)
File “/home/m/anaconda3/lib/python3.7/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 85, in forward
raise NotImplementedError
NotImplementedError:
Trace Shapes:
Param Sites:
Sample Sites:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/handlers.py”, line 466, in _fn
return ftr(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 153, in call
traceback)
File “/home/m/anaconda3/lib/python3.7/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/contrib/autoguide/init.py”, line 277, in call
self._setup_prototype(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/contrib/autoguide/init.py”, line 106, in _setup_prototype
self.prototype_trace = poutine.block(poutine.trace(self.model).get_trace)(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 169, in get_trace
self(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 153, in call
traceback)
File “/home/m/anaconda3/lib/python3.7/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 85, in forward
raise NotImplementedError
NotImplementedError:
Trace Shapes:
Param Sites:
Sample Sites:
Trace Shapes:
Param Sites:
Sample Sites:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/m/GitLab/code/aggregation_trial_4.py”, line 226, in
main(args)
File “/home/m/GitLab/code/aggregation_trial_4.py”, line 198, in main
= preprocess_minibatch(epoch, which_mini_batch, shuffled_indices)
File “/home/m/GitLab/code/aggregation_trial_4.py”, line 179, in preprocess_minibatch
loss = svi.step(mini_batch, mini_batch_mask, mini_batch_crowd_annotations, mini_batch_crowd_annotations_mask)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/infer/svi.py”, line 99, in step
loss = self.loss_and_grads(self.model, self.guide, *args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/infer/traceenum_elbo.py”, line 365, in loss_and_grads
for model_trace, guide_trace in self._get_traces(model, guide, *args, **kwargs):
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/infer/traceenum_elbo.py”, line 308, in _get_traces
yield self._get_trace(model, guide, *args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/infer/traceenum_elbo.py”, line 262, in _get_trace
“flat”, self.max_plate_nesting, model, guide, *args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/infer/enum.py”, line 42, in get_importance_trace
guide_trace = poutine.trace(guide, graph_type=graph_type).get_trace(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 169, in get_trace
self(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 153, in call
traceback)
File “/home/m/anaconda3/lib/python3.7/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/handlers.py”, line 466, in _fn
return ftr(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 153, in call
traceback)
File “/home/m/anaconda3/lib/python3.7/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/contrib/autoguide/init.py”, line 277, in call
self._setup_prototype(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/contrib/autoguide/init.py”, line 106, in _setup_prototype
self.prototype_trace = poutine.block(poutine.trace(self.model).get_trace)(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/messenger.py”, line 27, in _wraps
return fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 169, in get_trace
self(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 153, in call
traceback)
File “/home/m/anaconda3/lib/python3.7/site-packages/six.py”, line 692, in reraise
raise value.with_traceback(tb)
File “/home/m/anaconda3/lib/python3.7/site-packages/pyro/poutine/trace_messenger.py”, line 147, in call
ret = self.fn(*args, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “/home/m/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 85, in forward
raise NotImplementedError
NotImplementedError:
Trace Shapes:
Param Sites:
Sample Sites:
Trace Shapes:
Param Sites:
Sample Sites:
Trace Shapes:
Param Sites:
Sample Sites:

Hi, please post the code that produced the error. It looks like you passed a nn.Module to SVI as a model but did not implement the forward method of the module.

1 Like

Hi eb8680_2, thank you very much for your reply! Following your idea, I found my problem!

Because you reminded to find the nn.Module passed to the SVI, I checked the input of SVI. Then I realised I had a big bug. I did not pass the ‘model’ as the input. In my case, the ‘model’ is a function of my HMM class. I mistakenly pass the hmm as the input, i.e. SVI(hmm, …). Actually, the input should be hmm.model, i.e. SVI(hmm.model,…)