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
4480ce25
Commit
4480ce25
authored
6 years ago
by
Bas Nijholt
Browse files
Options
Downloads
Patches
Plain Diff
2D: create 'tell_pending' which deprecates 'tell(x, None)'
parent
982d69a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!107
Introduce 'tell_pending' which replaces 'tell(x, None)'
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
adaptive/learner/learner2D.py
+15
-13
15 additions, 13 deletions
adaptive/learner/learner2D.py
with
15 additions
and
13 deletions
adaptive/learner/learner2D.py
+
15
−
13
View file @
4480ce25
...
...
@@ -304,15 +304,15 @@ class Learner2D(BaseLearner):
def
tell
(
self
,
point
,
value
):
point
=
tuple
(
point
)
self
.
data
[
point
]
=
value
self
.
pending_points
.
discard
(
point
)
self
.
_ip
=
None
self
.
_stack
.
pop
(
point
,
None
)
if
value
is
None
:
self
.
pending_points
.
add
(
point
)
self
.
_ip_combined
=
None
else
:
self
.
data
[
point
]
=
value
self
.
pending_points
.
discard
(
point
)
self
.
_ip
=
None
def
tell_pending
(
self
,
point
):
point
=
tuple
(
point
)
self
.
pending_points
.
add
(
point
)
self
.
_ip_combined
=
None
self
.
_stack
.
pop
(
point
,
None
)
def
_fill_stack
(
self
,
stack_till
=
1
):
...
...
@@ -345,13 +345,14 @@ class Learner2D(BaseLearner):
return
points_new
,
losses_new
def
ask
(
self
,
n
,
add_data
=
True
):
# Even if
add_data
is False we add the point such that _fill_stack
def
ask
(
self
,
n
,
tell_pending
=
True
):
# Even if
tell_pending
is False we add the point such that _fill_stack
# will return new points, later we remove these points if needed.
points
=
list
(
self
.
_stack
.
keys
())
loss_improvements
=
list
(
self
.
_stack
.
values
())
n_left
=
n
-
len
(
points
)
self
.
tell_many
(
points
[:
n
],
itertools
.
repeat
(
None
))
for
p
in
points
[:
n
]:
self
.
tell_pending
(
p
)
while
n_left
>
0
:
# The while loop is needed because `stack_till` could be larger
...
...
@@ -359,13 +360,14 @@ class Learner2D(BaseLearner):
# it could fill up till a length smaller than `stack_till`.
new_points
,
new_loss_improvements
=
self
.
_fill_stack
(
stack_till
=
max
(
n_left
,
self
.
stack_size
))
self
.
tell_many
(
new_points
[:
n_left
],
itertools
.
repeat
(
None
))
for
p
in
points
[:
n_left
]:
self
.
tell_pending
(
p
)
n_left
-=
len
(
new_points
)
points
+=
new_points
loss_improvements
+=
new_loss_improvements
if
not
add_data
:
if
not
tell_pending
:
self
.
_stack
=
OrderedDict
(
zip
(
points
[:
self
.
stack_size
],
loss_improvements
))
for
point
in
points
[:
n
]:
...
...
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