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
Merge requests
!134
change resolution_loss to a factory function
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
change resolution_loss to a factory function
loss_functions
into
master
Overview
0
Commits
1
Pipelines
2
Changes
3
Merged
Bas Nijholt
requested to merge
loss_functions
into
master
6 years ago
Overview
0
Commits
1
Pipelines
2
Changes
3
Expand
0
0
Merge request reports
Compare
master
version 1
2f7502b5
6 years ago
master (base)
and
latest version
latest version
9dcc5f18
1 commit,
6 years ago
version 1
2f7502b5
1 commit,
6 years ago
3 files
+
25
−
40
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
adaptive/learner/learner2D.py
+
11
−
14
Options
@@ -89,7 +89,7 @@ def uniform_loss(ip):
return
np
.
sqrt
(
areas
(
ip
))
def
resolution_loss
(
ip
,
min_distance
=
0
,
max_distance
=
1
):
def
resolution_loss
_function
(
min_distance
=
0
,
max_distance
=
1
):
"""
Loss function that is similar to the `default_loss` function, but you
can set the maximimum and minimum size of a triangle.
@@ -104,27 +104,24 @@ def resolution_loss(ip, min_distance=0, max_distance=1):
...
x
,
y
=
xy
...
return
x
**
2
+
y
**
2
>>>
>>>
from
functools
import
partial
>>>
loss
=
partial
(
resolution_loss
,
min_distance
=
0.01
)
>>>
loss
=
resolution_loss_function
(
min_distance
=
0.01
,
max_distance
=
1
)
>>>
learner
=
adaptive
.
Learner2D
(
f
,
...
bounds
=
[(
-
1
,
-
1
),
(
1
,
1
)],
...
loss_per_triangle
=
loss
)
>>>
"""
A
=
areas
(
ip
)
dev
=
np
.
sum
(
deviations
(
ip
),
axis
=
0
)
# similar to the default_loss
loss
=
np
.
sqrt
(
A
)
*
dev
+
A
def
resolution_loss
(
ip
):
loss
=
default_loss
(
ip
)
# Setting areas with a small area to zero such that they won't be chosen again
loss
[
A
<
min_distance
**
2
]
=
0
# Setting areas with a small area to zero such that they won't be chosen again
loss
[
A
<
min_distance
**
2
]
=
0
# Setting triangles that have a size larger than max_distance to infinite loss
# such that these triangles will be picked
loss
[
A
>
max_distance
**
2
]
=
np
.
inf
# Setting triangles that have a size larger than max_distance to infinite loss
# such that these triangles will be picked
loss
[
A
>
max_distance
**
2
]
=
np
.
inf
return
loss
return
loss
return
resolution_loss
def
minimize_triangle_surface_loss
(
ip
):
Loading