Open luningsun opened 2 years ago
Hi @luningsun, sorry for the late reply!
I looked into it, and I believe there was some change to hamiltorch
, so I get the same error. I managed to get it to work by changing the network definition, to a more simple, explicit version:
class RegNet(nn.Sequential):
def __init__(self):
super(RegNet, self).__init__()
self.l1 = torch.nn.Linear(2, 10)
self.l2 = torch.nn.Linear(10, 10)
self.l3 = torch.nn.Linear(10, 10)
self.l4 = torch.nn.Linear(10, 10)
self.l5 = torch.nn.Linear(10, 1)
def forward(self, x):
x = self.l1(x)
x = torch.nn.functional.relu(x)
x = self.l2(x)
x = torch.nn.functional.relu(x)
x = self.l3(x)
x = torch.nn.functional.relu(x)
x = self.l4(x)
x = torch.nn.functional.relu(x)
x = self.l5(x)
return x
It may be worth starting an issue at the hamiltorch github (https://github.com/AdamCobb/hamiltorch).
If you don't mind using JAX, I also have an implementation of HMC for a similar problem here: https://github.com/google-research/google-research/blob/master/bnn_hmc/notebooks/synthetic_regression_inference.ipynb.
Hi, guys.
I am very interested in the hmc example you show in the paper. However, when I run it I got an error ''Scope' object is not iterable'. And it seems an error from PyTorch. I tried a different version of PyTorch but the error still exists. Below is the detailed error message. I wonder if you have come across similar questions and if you could help me solve them.
TypeError Traceback (most recent call last)