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
!121
2D: add loss that minimizes the area of the triangle in 3D
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
2D: add loss that minimizes the area of the triangle in 3D
loss_like_1d_in_2d
into
master
Overview
0
Commits
1
Pipelines
5
Changes
1
Merged
Bas Nijholt
requested to merge
loss_like_1d_in_2d
into
master
6 years ago
Overview
0
Commits
1
Pipelines
5
Changes
1
Expand
This is similar to the default loss in the
Learner1D
It results in:
0
0
Merge request reports
Compare
master
version 4
4a211ec8
6 years ago
version 3
8bc3f16a
6 years ago
version 2
ec32933a
6 years ago
version 1
2cc22c90
6 years ago
master (base)
and
version 2
latest version
b5b81acc
1 commit,
6 years ago
version 4
4a211ec8
1 commit,
6 years ago
version 3
8bc3f16a
1 commit,
6 years ago
version 2
ec32933a
1 commit,
6 years ago
version 1
2cc22c90
2 commits,
6 years ago
1 file
+
38
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
adaptive/learner/learner2D.py
+
38
−
0
Options
@@ -99,6 +99,44 @@ def resolution_loss(ip, min_distance=0, max_distance=1):
return
loss
def
minimize_triangle_surface_loss
(
ip
):
"""
Loss function that is similar to the default loss function in the
`Learner1D`. The loss is the area spanned by the 3D vectors of the
vertices.
Works with `~adaptive.Learner2D` only.
Examples
--------
>>>
from
adaptive.learner.learner2D
import
minimize_triangle_surface_loss
>>>
def
f
(
xy
):
...
x
,
y
=
xy
...
return
x
**
2
+
y
**
2
>>>
>>>
learner
=
adaptive
.
Learner2D
(
f
,
bounds
=
[(
-
1
,
-
1
),
(
1
,
1
)],
...
loss_per_triangle
=
minimize_triangle_surface_loss
)
>>>
"""
tri
=
ip
.
tri
points
=
tri
.
points
[
tri
.
vertices
]
values
=
ip
.
values
[
tri
.
vertices
]
delta_pts
=
points
-
points
[:,
-
1
,
:][:,
None
,
:]
vectors
=
delta_pts
[:,
:
2
,
:]
a_xy
=
vectors
[:,
0
,
:]
b_xy
=
vectors
[:,
1
,
:]
delta_vals
=
values
-
values
[:,
-
1
,
:][:,
None
,
:]
vectors
=
delta_vals
[:,
:
2
,
:]
a_z
=
vectors
[:,
0
,
:]
b_z
=
vectors
[:,
1
,
:]
a
=
np
.
hstack
([
a_xy
,
a_z
])
b
=
np
.
hstack
([
b_xy
,
b_z
])
return
np
.
linalg
.
norm
(
np
.
cross
(
a
,
b
),
axis
=
1
)
def
default_loss
(
ip
):
dev
=
np
.
sum
(
deviations
(
ip
),
axis
=
0
)
A
=
areas
(
ip
)
Loading