Skip to content

Comments

Fix small bug#2974

Merged
ColCarroll merged 1 commit intopymc-devs:masterfrom
ColCarroll:fix_typo
May 15, 2018
Merged

Fix small bug#2974
ColCarroll merged 1 commit intopymc-devs:masterfrom
ColCarroll:fix_typo

Conversation

@ColCarroll
Copy link
Member

This looks like a typo, and probably caused funny slicing problems when sampling twice from a model in the past. draws_idx is not used anywhere else in the project.

@junpenglao
Copy link
Member

Good catch!
I guess this is for when you continue sampling and stacking the sample to an old trace? didnt realized this is possible.

@ColCarroll
Copy link
Member Author

Yep. I believe you can do something like

with pm.Model() as model:
    ...
    trace = pm.sample()

...
with model:
    trace = pm.sample(trace=trace)

I spotted it while working on a tiny utility to allow

with pm.Model() as model:
    ...
    trace = pm.sample()

pm.save_trace(trace, 'eight_schools.trace')
...
with model:
    trace = pm.load_trace('eight_schools.trace')

Initializing the trace needs to have access to the model for historical reasons...

@junpenglao
Copy link
Member

Cool!
Is this recommended? My biggest question to it is that since the previous trace is after tunning, and I suppose the next trace will start from 0 and tune again there is a risk that the chain is not in equilibrium any more? Maybe a warning should be print for this usage...

@ColCarroll
Copy link
Member Author

Yes - I do not think this use case has been thought about/maintained in a long time - serializing tuning data seems difficult.

Even for saving/loading the trace, the use case I am considering is a Jupyter notebook, where I would like to run the analysis once, but be able to reload the posterior samples later, perhaps on another machine.

@ColCarroll ColCarroll merged commit 0cc16ef into pymc-devs:master May 15, 2018
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

Successfully merging this pull request may close these issues.

2 participants