Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lscsoft
bilby
Commits
17dc18b7
There was a problem fetching the pipeline summary.
Commit
17dc18b7
authored
6 years ago
by
Colm Talbot
Browse files
Options
Downloads
Plain Diff
Merge branch 'automate-emcee-burnin' into 'master'
Closes
#141
Closes
#141
See merge request Monash/tupak!112
parents
90f1c761
6b60faee
No related branches found
No related tags found
1 merge request
!112
Closes #141
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tupak/core/sampler.py
+41
-8
41 additions, 8 deletions
tupak/core/sampler.py
with
41 additions
and
8 deletions
tupak/core/sampler.py
+
41
−
8
View file @
17dc18b7
...
...
@@ -773,7 +773,9 @@ class Emcee(Sampler):
def
_run_external_sampler
(
self
):
self
.
nwalkers
=
self
.
kwargs
.
get
(
'
nwalkers
'
,
100
)
self
.
nsteps
=
self
.
kwargs
.
get
(
'
nsteps
'
,
100
)
self
.
nburn
=
self
.
kwargs
.
get
(
'
nburn
'
,
50
)
self
.
nburn
=
self
.
kwargs
.
get
(
'
nburn
'
,
None
)
self
.
burn_in_fraction
=
self
.
kwargs
.
get
(
'
burn_in_fraction
'
,
0.25
)
self
.
burn_in_act
=
self
.
kwargs
.
get
(
'
burn_in_act
'
,
3
)
a
=
self
.
kwargs
.
get
(
'
a
'
,
2
)
emcee
=
self
.
external_sampler
tqdm
=
utils
.
get_progress_bar
(
self
.
kwargs
.
pop
(
'
tqdm
'
,
'
tqdm
'
))
...
...
@@ -806,18 +808,14 @@ class Emcee(Sampler):
pass
self
.
result
.
sampler_output
=
np
.
nan
self
.
calculate_autocorrelation
(
sampler
)
self
.
setup_nburn
()
self
.
result
.
nburn
=
self
.
nburn
self
.
result
.
samples
=
sampler
.
chain
[:,
self
.
nburn
:,
:].
reshape
(
(
-
1
,
self
.
ndim
))
self
.
result
.
walkers
=
sampler
.
chain
[:,
:,
:]
self
.
result
.
nburn
=
self
.
nburn
self
.
result
.
log_evidence
=
np
.
nan
self
.
result
.
log_evidence_err
=
np
.
nan
try
:
logger
.
info
(
"
Max autocorr time = {}
"
.
format
(
np
.
max
(
sampler
.
get_autocorr_time
())))
except
emcee
.
autocorr
.
AutocorrError
as
e
:
logger
.
info
(
"
Unable to calculate autocorr time: {}
"
.
format
(
e
))
return
self
.
result
def
lnpostfn
(
self
,
theta
):
...
...
@@ -827,6 +825,41 @@ class Emcee(Sampler):
else
:
return
self
.
log_likelihood
(
theta
)
+
p
def
setup_nburn
(
self
):
"""
Handles calculating nburn, either from a given value or inferred
"""
if
type
(
self
.
nburn
)
in
[
float
,
int
]:
self
.
nburn
=
int
(
self
.
nburn
)
logger
.
info
(
"
Discarding {} steps for burn-in
"
.
format
(
self
.
nburn
))
elif
self
.
result
.
max_autocorrelation_time
is
None
:
self
.
nburn
=
int
(
self
.
burn_in_fraction
*
self
.
nsteps
)
logger
.
info
(
"
Autocorrelation time not calculated, discarding {}
"
"
steps for burn-in
"
.
format
(
self
.
nburn
))
else
:
self
.
nburn
=
int
(
self
.
burn_in_act
*
self
.
result
.
max_autocorrelation_time
)
logger
.
info
(
"
Discarding {} steps for burn-in, estimated from
"
"
autocorr
"
.
format
(
self
.
nburn
))
def
calculate_autocorrelation
(
self
,
sampler
,
c
=
3
):
"""
Uses the `emcee.autocorr` module to estimate the autocorrelation
Parameters
----------
c: float
The minimum number of autocorrelation times needed to trust the
estimate (default: `3`). See `emcee.autocorr.integrated_time`.
"""
import
emcee
try
:
self
.
result
.
max_autocorrelation_time
=
int
(
np
.
max
(
sampler
.
get_autocorr_time
(
c
=
c
)))
logger
.
info
(
"
Max autocorr time = {}
"
.
format
(
self
.
result
.
max_autocorrelation_time
))
except
emcee
.
autocorr
.
AutocorrError
as
e
:
self
.
result
.
max_autocorrelation_time
=
None
logger
.
info
(
"
Unable to calculate autocorr time: {}
"
.
format
(
e
))
class
Ptemcee
(
Emcee
):
"""
https://github.com/willvousden/ptemcee
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment