In [7]:
import numpy as np

import imcmc
In [16]:
# Rerun this cell until the image looks good
np.random.seed(8)
image = imcmc.load_image('python.png', 'L')
trace = imcmc.sample_grayscale(image, samples=1000, tune=500, nchains=6, threshold=0.1)
imcmc.plot_multitrace(trace, image, marker='o', markersize=10, colors=['#0000FF','#0000FF', '#FFFF00'], alpha=1);
Multiprocess sampling (6 chains in 2 jobs)
Metropolis: [image]
100%|█████████▉| 1494/1500 [00:00<00:00, 1865.37it/s]
100%|██████████| 1500/1500 [00:00<00:00, 1862.78it/s]The estimated number of effective samples is smaller than 200 for some parameters.
In [17]:
# Then run this step on the final image to get the samplers drawing it
imcmc.make_gif(trace, image, dpi=40, marker='o', 
               markersize=10, colors=['#0000FF','#0000FF', '#FFFF00'], 
               alpha=1, leading_point=False, filename='python.gif')
Out[17]:
'python.gif'
In [20]:
# Rerun this cell until the image looks good
np.random.seed(2)
image = imcmc.load_image('pymc3-logo.png', 'L')
trace = imcmc.sample_grayscale(image, samples=5000, tune=500, nchains=7)
imcmc.plot_multitrace(trace, image, marker='o', alpha=0.5);
Multiprocess sampling (7 chains in 2 jobs)
Metropolis: [image]
2
100%|██████████| 5500/5500 [00:00<00:00, 6760.44it/s]
The gelman-rubin statistic is larger than 1.2 for some parameters.
The estimated number of effective samples is smaller than 200 for some parameters.
In [33]:
# Then run this step on the final image to get the samplers drawing it
imcmc.make_gif(trace, image, dpi=40, marker='', linestyle='-', alpha=0.35, filename='pymc3.gif')
Out[33]:
'pymc3.gif'
In [54]:
# Rerun this cell until the image looks good
seed += 1
np.random.seed(18)
print(seed)
image = imcmc.load_image('civic.png', 'L')
trace = imcmc.sample_grayscale(image, samples=1000, tune=500, nchains=98)
imcmc.plot_multitrace(trace, image, marker=',', alpha=1);
18
Multiprocess sampling (98 chains in 2 jobs)
Metropolis: [image]
100%|██████████| 1500/1500 [00:00<00:00, 5639.67it/s]
The gelman-rubin statistic is larger than 1.4 for some parameters. The sampler did not converge.
The estimated number of effective samples is smaller than 200 for some parameters.
In [56]:
# Then run this step on the final image to get the samplers drawing it
imcmc.make_gif(trace, image, dpi=40, marker=',', leading_point=False, alpha=1, filename='civic.gif')
Out[56]:
'civic.gif'
In [63]:
# Rerun this cell until the image looks good
seed += 1
np.random.seed(6)
print(seed)
image = imcmc.load_image('matplotlib.png', 'L')
trace = imcmc.sample_grayscale(image, samples=2000, tune=500, nchains=7)
imcmc.plot_multitrace(trace, image, marker='.', linestyle='-', alpha=0.5);
Multiprocess sampling (7 chains in 2 jobs)
Metropolis: [image]
6
100%|██████████| 2500/2500 [00:00<00:00, 6298.96it/s]
The gelman-rubin statistic is larger than 1.4 for some parameters. The sampler did not converge.
The estimated number of effective samples is smaller than 200 for some parameters.
In [65]:
imcmc.make_gif(trace, image, dpi=40, marker='.', linestyle='-', alpha=0.3, filename='matplotlib.gif')
Out[65]:
'matplotlib.gif'
In [66]:
seed = 0
In [80]:
# Rerun this cell until the image looks good
seed += 1
np.random.seed(10)
print(seed)
image = imcmc.load_image('scipy.png', 'L')
trace = imcmc.sample_grayscale(image, samples=1000, tune=500, nchains=5)
imcmc.plot_multitrace(trace, image, marker='o', linestyle='', alpha=0.5);
Multiprocess sampling (5 chains in 2 jobs)
Metropolis: [image]
10
100%|██████████| 1500/1500 [00:00<00:00, 6106.53it/s]
The gelman-rubin statistic is larger than 1.05 for some parameters. This indicates slight problems during sampling.
The estimated number of effective samples is smaller than 200 for some parameters.