pymc3

Multidimensional PyMC3 Observations

女生的网名这么多〃 提交于 2020-03-03 07:09:27
问题 My model has a LogNormal RV, C, of shape (W,D). Each row in W and each column in D has a parameter that is being fit. I have tried to specify my observations as a (W,D) matrix, however, that is leading to a theano compile error raise Exception('Compilation failed (return status=%s): %s' % Exception: ('The following error happened while compiling the node', Alloc(Elemwise{switch,no_inplace}.0, TensorConstant{10}, TensorConstant{10}), '\n', 'Compilation failed (return status=3): ', '[Alloc(

Multidimensional PyMC3 Observations

空扰寡人 提交于 2020-03-03 07:08:29
问题 My model has a LogNormal RV, C, of shape (W,D). Each row in W and each column in D has a parameter that is being fit. I have tried to specify my observations as a (W,D) matrix, however, that is leading to a theano compile error raise Exception('Compilation failed (return status=%s): %s' % Exception: ('The following error happened while compiling the node', Alloc(Elemwise{switch,no_inplace}.0, TensorConstant{10}, TensorConstant{10}), '\n', 'Compilation failed (return status=3): ', '[Alloc(

Is there any way to increase memory assigned to jupyter notebook

孤者浪人 提交于 2020-02-27 04:01:35
问题 I am using python3.6 My jupyter notebook is crashing again and again when I try to run NUTS sampling in pymc3. My laptop has 16gb and i7 I think it should be enough. I ran same code on 8gb and i7 laptop and it worked that time. Not able to fig out what the issue is in this one. I have generated the config file for jupyter with this command $ jupyter notebook --generate-config I am not able to fig out which parameter I need to modify to tackle this issue. This is code I am using with pm.Model(

Problems with a hidden Markov model in PyMC3

吃可爱长大的小学妹 提交于 2020-02-01 19:59:30
问题 To learn PyMC, I'm trying to do a simple Hidden Markov Model as shown below: with pymc3.Model() as hmm: # Transition "matrix" a_t = np.ones(num_states) T = [pymc3.Dirichlet('T{0}'.format(i), a = a_t, shape = num_states) for i in xrange(num_states)] # Emission "matrix" a_e = np.ones(num_emissions) E = [pymc3.Dirichlet('E{0}'.format(i), a = a_e, shape = num_emissions) for i in xrange(num_states)] # State models p0 = np.ones(num_states) / num_states # No shape, so each state is a scalar tensor

Multivariate linear regression in pymc3

自古美人都是妖i 提交于 2020-02-01 09:03:12
问题 I've recently started learning pymc3 after exclusively using emcee for ages and I'm running into some conceptual problems. I'm practising with Chapter 7 of Hogg's Fitting a model to data. This involves a mcmc fit to a straight line with arbitrary 2d uncertainties. I've accomplished this quite easily in emcee , but pymc is giving me some problems. It essentially boils down to using a multivariate gaussian likelihood. Here is what I have so far. from pymc3 import * import numpy as np import

pymc3 Multi-category Bayesian network - how to sample?

醉酒当歌 提交于 2020-01-25 22:04:14
问题 I have set up a Bayes net with 3 states per node as below, and can read logp's for particular states from it (as in the code). Next I would like to sample from it. In the code below, sampling runs but I don't see distributions over the three states in the outputs; rather, I see a mean and variance as if they were continuous nodes. How do I get the posterior over the three states? import numpy as np import pymc3 as mc import pylab, math model = mc.Model() with model: rain = mc.Categorical(

how to calculate log posterior of a GP over a trace in pymc3

眉间皱痕 提交于 2020-01-06 05:56:07
问题 Use case Suppose I have an observation y_0 at X_0 which I'd like to model with a Gaussian process with hyper params theta . Suppose I then determine a distribution in the hyper params theta by hierarchically sampling the posterior. Now, I'd like to evaluate the log posterior probability of another observation say y_1 at X_1 , averaged over the hyper param distribution, E_theta [ log P(y_1 | y_0, X_0, X_1, theta) ] Ideally, I'd draw from the posterior in theta and calculate log P(y_1 | y_0, X

Using a complex likelihood in PyMC3

冷暖自知 提交于 2020-01-01 11:54:11
问题 pymc.__version__ = '3.0' theano.__version__ = '0.6.0.dev-RELEASE' I'm trying to use PyMC3 with a complex likelihood function: First question: Is this possible? Here's my attempt using Thomas Wiecki's post as a guide: import numpy as np import theano as th import pymc as pm import scipy as sp # Actual data I'm trying to fit x = np.array([52.08, 58.44, 60.0, 65.0, 65.10, 66.0, 70.0, 87.5, 110.0, 126.0]) y = np.array([0.522, 0.659, 0.462, 0.720, 0.609, 0.696, 0.667, 0.870, 0.889, 0.919]) yerr =

Unable to create lambda function in hierarchical pymc3 model

北城以北 提交于 2019-12-31 04:17:42
问题 I'm trying to create the model shown below with PyMC 3 but can't figure out how to properly map probabilities to the observed data with a lambda function. import numpy as np import pymc as pm data = np.array([[0, 0, 1, 1, 2], [0, 1, 2, 2, 2], [2, 2, 1, 1, 0], [1, 1, 2, 0, 1]]) (D, W) = data.shape V = len(set(data.ravel())) T = 3 a = np.ones(T) b = np.ones(V) with pm.Model() as model: theta = [pm.Dirichlet('theta_%s' % i, a, shape=T) for i in range(D)] z = [pm.Categorical('z_%i' % i, theta[i],

Dirichlet process in PyMC 3

偶尔善良 提交于 2019-12-24 00:20:49
问题 I would like to implement to implement the Dirichlet process example referenced in Implementing Dirichlet processes for Bayesian semi-parametric models (source: here) in PyMC 3. In the example the stick-breaking probabilities are computed using the pymc.deterministic decorator: v = pymc.Beta('v', alpha=1, beta=alpha, size=N_dp) @pymc.deterministic def p(v=v): """ Calculate Dirichlet probabilities """ # Probabilities from betas value = [u*np.prod(1-v[:i]) for i,u in enumerate(v)] # Enforce sum