Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Climax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Show more breadcrumbs
earth_observation_public
Climax
Commits
7b6fa4e7
Commit
7b6fa4e7
authored
3 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Implemented median reduction.
parent
1cbb8233
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
climax/core/loss.py
+4
-6
4 additions, 6 deletions
climax/core/loss.py
with
4 additions
and
6 deletions
climax/core/loss.py
+
4
−
6
View file @
7b6fa4e7
...
@@ -26,6 +26,8 @@ class NaNLoss(_Loss):
...
@@ -26,6 +26,8 @@ class NaNLoss(_Loss):
return
tensor
.
mean
()
return
tensor
.
mean
()
elif
self
.
reduction
==
'
sum
'
:
elif
self
.
reduction
==
'
sum
'
:
return
tensor
.
sum
()
return
tensor
.
sum
()
elif
self
.
reduction
==
'
median
'
:
return
tensor
.
median
()
class
MSELoss
(
NaNLoss
):
class
MSELoss
(
NaNLoss
):
...
@@ -133,13 +135,9 @@ class BernoulliWeibullLoss(BernoulliLoss):
...
@@ -133,13 +135,9 @@ class BernoulliWeibullLoss(BernoulliLoss):
# clip probabilities to (0, 1)
# clip probabilities to (0, 1)
p_pred
=
torch
.
sigmoid
(
y_pred
[:,
0
,
...].
squeeze
()[
mask
])
p_pred
=
torch
.
sigmoid
(
y_pred
[:,
0
,
...].
squeeze
()[
mask
])
# clip scale to (0, +infinity)
# clip shape and scale to (0, +infinity)
scale
=
torch
.
exp
(
y_pred
[:,
2
,
...].
squeeze
()[
mask
][
~
mask_p
])
# clip shape to (0, 10)
# NOTE: in general shape in (0, +infinity), clipping is required for
# numerical stability
shape
=
torch
.
exp
(
y_pred
[:,
1
,
...].
squeeze
()[
mask
][
~
mask_p
])
shape
=
torch
.
exp
(
y_pred
[:,
1
,
...].
squeeze
()[
mask
][
~
mask_p
])
scale
=
torch
.
exp
(
y_pred
[:,
2
,
...].
squeeze
()[
mask
][
~
mask_p
])
# negative log-likelihood function of Bernoulli-Weibull distribution
# negative log-likelihood function of Bernoulli-Weibull distribution
loss
=
torch
.
zeros_like
(
y_true
)
loss
=
torch
.
zeros_like
(
y_true
)
...
...
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