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
4457fd69
Commit
4457fd69
authored
7 years ago
by
Joseph Weston
Browse files
Options
Downloads
Patches
Plain Diff
improve docstrings
parent
18212a81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
adaptive/learner.py
+30
-6
30 additions, 6 deletions
adaptive/learner.py
with
30 additions
and
6 deletions
adaptive/learner.py
+
30
−
6
View file @
4457fd69
...
@@ -54,10 +54,30 @@ class BaseLearner(metaclass=abc.ABCMeta):
...
@@ -54,10 +54,30 @@ class BaseLearner(metaclass=abc.ABCMeta):
self
.
data
=
{
k
:
v
for
k
,
v
in
self
.
data
.
items
()
if
v
is
not
None
}
self
.
data
=
{
k
:
v
for
k
,
v
in
self
.
data
.
items
()
if
v
is
not
None
}
@abc.abstractmethod
@abc.abstractmethod
def
loss
(
self
):
def
loss
(
self
,
expected
=
False
):
pass
"""
Return the loss for the current state of the learner.
Parameters
----------
expected : bool, default: False
If True, return the
"
expected
"
loss, i.e. the
loss including the as-yet unevaluated points
(possibly by interpolation).
"""
def
choose_points
(
self
,
n
,
add_data
=
True
):
def
choose_points
(
self
,
n
,
add_data
=
True
):
"""
Choose the next
'
n
'
points to evaluate.
Parameters
----------
n : int
The number of points to choose.
add_data : bool, default: True
If True, add the chosen points to this
learner
'
s
'
data
'
with
'
None
'
for the
'
y
'
values. Set this to False if you do not
want to modify the state of the learner.
"""
points
=
self
.
_choose_points
(
n
)
points
=
self
.
_choose_points
(
n
)
if
add_data
:
if
add_data
:
self
.
add_data
(
points
,
itertools
.
repeat
(
None
))
self
.
add_data
(
points
,
itertools
.
repeat
(
None
))
...
@@ -65,11 +85,15 @@ class BaseLearner(metaclass=abc.ABCMeta):
...
@@ -65,11 +85,15 @@ class BaseLearner(metaclass=abc.ABCMeta):
@abc.abstractmethod
@abc.abstractmethod
def
_choose_points
(
self
,
n
):
def
_choose_points
(
self
,
n
):
pass
"""
Choose the next
'
n
'
points to evaluate.
@abc.abstractmethod
Should be overridden by subclasses.
def
interpolate
(
self
):
pass
Parameters
----------
n : int
The number of points to choose.
"""
class
Learner1D
(
BaseLearner
):
class
Learner1D
(
BaseLearner
):
...
...
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