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
87eca332
Commit
87eca332
authored
6 years ago
by
Bas Nijholt
Browse files
Options
Downloads
Patches
Plain Diff
dedent common code in 'update_losses'
parent
2a03f093
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!100
Resolve "Learner1D doesn't correctly set the interpolated loss when a point is added"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
adaptive/learner/learner1D.py
+8
-7
8 additions, 7 deletions
adaptive/learner/learner1D.py
with
8 additions
and
7 deletions
adaptive/learner/learner1D.py
+
8
−
7
View file @
87eca332
...
...
@@ -147,22 +147,23 @@ class Learner1D(BaseLearner):
self
.
losses_combined
[
x_left
,
x_right
]
=
loss
def
update_losses
(
self
,
x
,
real
=
True
):
a
,
b
=
self
.
find_neighbors
(
x
,
self
.
neighbors_combined
)
x_left
,
x_right
=
self
.
find_neighbors
(
x
,
self
.
neighbors
)
losses_combined
=
self
.
losses_combined
if
real
:
x_left
,
x_right
=
self
.
find_neighbors
(
x
,
self
.
neighbors
)
self
.
update_interpolated_loss_in_interval
(
x_left
,
x
)
self
.
update_interpolated_loss_in_interval
(
x
,
x_right
)
self
.
losses
.
pop
((
x_left
,
x_right
),
None
)
self
.
losses_combined
.
pop
((
x_left
,
x_right
),
None
)
a
,
b
=
self
.
find_neighbors
(
x
,
self
.
neighbors_combined
)
self
.
losses_combined
.
pop
((
a
,
b
),
None
)
if
x_left
is
None
and
a
is
not
None
:
self
.
losses_combined
[
a
,
x
]
=
float
(
'
inf
'
)
losses_combined
[
a
,
x
]
=
float
(
'
inf
'
)
if
x_right
is
None
and
b
is
not
None
:
self
.
losses_combined
[
x
,
b
]
=
float
(
'
inf
'
)
losses_combined
[
x
,
b
]
=
float
(
'
inf
'
)
else
:
losses_combined
=
self
.
losses_combined
x_left
,
x_right
=
self
.
find_neighbors
(
x
,
self
.
neighbors
)
a
,
b
=
self
.
find_neighbors
(
x
,
self
.
neighbors_combined
)
if
x_left
is
not
None
and
x_right
is
not
None
:
dx
=
x_right
-
x_left
loss
=
self
.
losses
[
x_left
,
x_right
]
...
...
@@ -174,7 +175,7 @@ class Learner1D(BaseLearner):
if
b
is
not
None
:
losses_combined
[
x
,
b
]
=
float
(
'
inf
'
)
losses_combined
.
pop
((
a
,
b
),
None
)
losses_combined
.
pop
((
a
,
b
),
None
)
def
find_neighbors
(
self
,
x
,
neighbors
):
if
x
in
neighbors
:
...
...
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