Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
adaptive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Quantum Tinkerer
adaptive
Commits
05a35c3e
Commit
05a35c3e
authored
7 years ago
by
Bas Nijholt
Browse files
Options
Downloads
Patches
Plain Diff
small style updates
parent
84d8abb2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
implement 2D learner
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
adaptive/learner.py
+15
-13
15 additions, 13 deletions
adaptive/learner.py
with
15 additions
and
13 deletions
adaptive/learner.py
+
15
−
13
View file @
05a35c3e
...
...
@@ -29,6 +29,7 @@ class BaseLearner(metaclass=abc.ABCMeta):
Subclasses may define a
'
plot
'
method that takes no parameters
and returns a holoviews plot.
"""
def
__init__
(
self
,
function
):
self
.
data
=
{}
self
.
function
=
function
...
...
@@ -97,19 +98,20 @@ class BaseLearner(metaclass=abc.ABCMeta):
class
AverageLearner
(
BaseLearner
):
def
__init__
(
self
,
function
,
atol
=
None
,
rtol
=
None
):
"""
A naive implementation of adaptive computing of averages.
"""
A naive implementation of adaptive computing of averages.
The learned function must depend on an integer input variable that
represents the source of randomness.
The learned function must depend on an integer input variable that
represents the source of randomness.
Parameters:
-----------
atol : float
Desired absolute tolerance
rtol : float
Desired relative tolerance
"""
Parameters:
-----------
atol : float
Desired absolute tolerance
rtol : float
Desired relative tolerance
"""
def
__init__
(
self
,
function
,
atol
=
None
,
rtol
=
None
):
super
().
__init__
(
function
)
if
atol
is
None
and
rtol
is
None
:
...
...
@@ -419,6 +421,7 @@ class BalancingLearner(BaseLearner):
of the same type*. In this case the BalancingLearner will behave in an
undefined way.
"""
def
__init__
(
self
,
learners
):
self
.
learners
=
learners
...
...
@@ -448,7 +451,7 @@ class BalancingLearner(BaseLearner):
return
points
,
None
def
choose_points
(
self
,
n
,
add_data
=
True
):
"""
Chose
s
points for learners.
"""
"""
Chose points for learners.
"""
if
not
add_data
:
with
restore
(
*
self
.
learners
):
return
self
.
_choose_and_add_points
(
n
)
...
...
@@ -681,7 +684,6 @@ class Learner2D(BaseLearner):
self
.
n
+=
1
def
_fill_stack
(
self
,
stack_till
=
None
):
# Deal with periodicity: extend by one period
p
=
self
.
points
v
=
self
.
values
...
...
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