I’m attempting to combine the successful elements of James’ code with the base tutorial: even though my suspicion is that the model itself needs a nonlinear nn.Sigmoid layer, I’ve left that out for now. Here’s how I’ve specified the model call (I’ve left the guide the same as in the tutorial) and the data generator (straight from James’ code):

```
def build_linear_dataset(N, p=1, noise_std=0.01):
X = np.random.rand(N, p)
# w = 3
w = 3 * np.ones(p)
# b = 1
y = np.matmul(X, w) + np.repeat(1, N) + np.random.normal(0, noise_std, size=N)
y = y.reshape(N, 1)
X, y = torch.tensor(X).type(torch.Tensor), torch.tensor(y).type(torch.Tensor)
data = torch.cat((X, y), 1)
assert data.shape == (N, p + 1)
return data
def model(data):
# Create unit normal priors over the parameters
loc, scale = torch.zeros(1, 1), 10 * torch.ones(1, 1)
bias_loc, bias_scale = torch.zeros(1), 10 * torch.ones(1)
w_prior = Normal(loc, scale).independent(1)
b_prior = Normal(bias_loc, bias_scale).independent(1)
priors = {'linear.weight': w_prior, 'linear.bias': b_prior}
lifted_module = pyro.random_module("module", regression_model, priors)
lifted_reg_model = lifted_module()
with pyro.iarange("map", N):
x_data = data[:, :-1]
y_data = data[:, -1]
model_logits = lifted_reg_model(x_data)
#model_logits = (torch.matmul(x, weights_prior.permute(1, 0)) + bias_prior).squeeze()
pyro.sample("obs", Bernoulli(logits=model_logits, validate_args=True), obs=y_data.squeeze())
```

Here’s the error I’m getting when I attempt to run the SVI:

I based this on jpchen’s suggestions. What am I doing wrong?