ColCarroll / sampled

Decorator for PyMC3
MIT License
49 stars 6 forks source link

The example code does not work. #4

Closed MooersLab closed 6 years ago

MooersLab commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Many thanks Colin!

I works for me now!

Thank for this syntactic sugar. It looks to be very helpful.

On Thu, Dec 21, 2017 at 9:17 AM, Colin notifications@github.com wrote:

Closed #4 https://github.com/ColCarroll/sampled/issues/4.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ColCarroll/sampled/issues/4#event-1398154655, or mute the thread https://github.com/notifications/unsubscribe-auth/AOeSC33sGHnMLr7UqX-RLtd7N7WQA57Dks5tCnaPgaJpZM4Qrm6z .

-- Best regards,

Blaine

Blaine Mooers, Ph.D. Associate Professor Department of Biochemistry and Molecular Biology College of Medicine University of Oklahoma Health Sciences Center S.L. Young Biomedical Research Center Rm. 466 975 NE 10th Street https://maps.google.com/?q=975+NE+10th+Street&entry=gmail&source=g, BRC 466 Oklahoma City, OK 73104-5419

office: (405) 271-8300 lab: (405) 271-8313

Faculty webpage http://tinyurl.com/ouhscMooers X-ray lab (LBSF) http://research.ouhsc.edu/CoreFacilities/LaboratoryofBiomolecularStructureandFunction.aspx COBRE in Structural Biology http://structuralbiology.ou.edu/ SSRL UEC Facebook Page https://www.facebook.com/ssrluec/ SSRL UEC https://www-ssrl.slac.stanford.edu/content/about-ssrl/advisory-panels/ssrl-users-organization/members/ssrluo-2016-executive-committee-members SSRL SAC https://www-ssrl.slac.stanford.edu/content/about-ssrl/scientific-advisory-committee LCLS UEC https://www-ssrl.slac.stanford.edu/lcls-resources/lcls-users-organization-executive-committee

EasyPyMOL https://github.com/MooersLab/EasyPyMOL Molecular Graphics https://www.oumedicine.com/docs/default-source/ad-biochemistry-workfiles/moleculargraphicslinks.html

https://www.oumedicine.com/docs/default-source/ad-biochemistry-workfiles/MolecularGraphicsLinks.html Small Angle Scattering http://www.oumedicine.com/docs/default-source/ad-biochemistry-workfiles/small-angle-scattering-links-27aug2014.html?sfvrsn=0 office: (405) 271-8300 lab: (405) 271-8313 e-mail: blaine-mooers@ouhsc.edu (or bmooers1@gmail.com)