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

fast_progress with macOS Safari and Jupyter and can break MCMC sampling #3935

Closed
essandess opened this issue May 26, 2020 · 1 comment
Closed
Labels
macOS macOS related v3

Comments

@essandess
Copy link

I believe that this fast_progress issue AnswerDotAI/fastprogress#46 causes PyMC3’s .sample method to break on Safari and a Jupyter notebook. Possibly related issues:

This MWE causes high CPU and energy usage when run in Safari. There is an intermittent Safari error message in the Jupyter Notebook tab that says:

This web page has been reloaded because it was using significant energy

Reloading the web page during MCMC sampling causes the Python processes to stall.

This MWE code works fine in Chrome because Chrome doesn’t have this issue.

MWE modified from https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter3_MCMC/Ch3_IntroMCMC_PyMC3.ipynb

import numpy as np, pymc3 as pm, theano.tensor as tt

data = np.loadtxt("Chapter3_MCMC/data/mixture_data.csv", delimiter=",")

with pm.Model() as model:
    p1 = pm.Uniform('p', 0, 1)
    p2 = 1 - p1
    p = tt.stack([p1, p2])
    assignment = pm.Categorical("assignment", p, 
                                shape=data.shape[0],
                                testval=np.random.randint(0, 2, data.shape[0]))
with model:
    sds = pm.Uniform("sds", 0, 100, shape=2)
    centers = pm.Normal("centers", 
                        mu=np.array([120, 190]), 
                        sd=np.array([10, 10]), 
                        shape=2)
    
    center_i = pm.Deterministic('center_i', centers[assignment])
    sd_i = pm.Deterministic('sd_i', sds[assignment])
    
    # and to combine it with the observations:
    observations = pm.Normal("obs", mu=center_i, sd=sd_i, observed=data)

with model:
    step1 = pm.Metropolis(vars=[p, sds, centers])
    step2 = pm.CategoricalGibbsMetropolis(vars=[assignment])
    trace = pm.sample(25000, step=[step1, step2])
    
with model:
    trace = pm.sample(50000, step=[step1, step2], trace=trace)
@ricardoV94 ricardoV94 added v3 macOS macOS related labels Nov 20, 2022
@ricardoV94
Copy link
Member

Closing this as it seems unrelated to PyMC, and it refers to the last version

@ricardoV94 ricardoV94 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS macOS related v3
Projects
None yet
Development

No branches or pull requests

2 participants