Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The example code does not work. #4

Closed
MooersLab opened this issue Nov 27, 2017 · 3 comments
Closed

The example code does not work. #4

MooersLab opened this issue Nov 27, 2017 · 3 comments

Comments

@MooersLab
Copy link

I get the error message when using the example code:
I used python3.5 and

numpy version: 1.13.3
pymc3 version: 3.2

ValueError: Input dimension mis-match. (input[0].shape[1] = 1000, input[1].shape[1] = 10)

import numpy as np
import pymc3 as pm
from sampled import sampled

@SampleD
def linear_model(X, y):
shape = X.shape
X = pm.Normal('X', mu=np.mean(X, axis=0), sd=np.std(X, axis=0), shape=shape)
coefs = pm.Normal('coefs', mu=np.zeros(shape[1]), sd=np.ones(shape[1]), shape=shape[1])
pm.Normal('y', mu=np.dot(X, coefs), sd=np.ones(shape[0]), shape=shape[0])

X = np.random.normal(size=(1000, 10))
w = np.random.normal(size=10)
y = X.dot(w) + np.random.normal(scale=0.1, size=1000)

with linear_model(X=X, y=y):
sampled_coefs = pm.sample(draws=500, tune=500)

np.allclose(sampled_coefs.get_values('coefs').mean(axis=0), w, atol=0.1) # True

@ColCarroll
Copy link
Owner

Thanks for reporting, sorry for the delay, and just pushed a fix: swapped np.dot for theano.tensor.dot. I am not sure why that caused a problem, but I would guess the issue lies in PyMC3, Theano, or numpy, in that order of probability!

@MooersLab
Copy link
Author

I understand! Thank you very much for making the time to fix sampled. The two examples from the Readme.md document worked for me after I upgraded with

sudo -H python3.5 -m pip install --upgrade git+https://github.com/ColCarroll/sampled.git

@MooersLab
Copy link
Author

MooersLab commented Dec 21, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants