Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mednet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Show more breadcrumbs
medai
software
mednet
Commits
3da537d0
Commit
3da537d0
authored
1 year ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[data.dataset] Make function private
parent
4c65b4fb
No related branches found
No related tags found
1 merge request
!7
Reviewed DataModule design+docs+types
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ptbench/data/dataset.py
+3
-3
3 additions, 3 deletions
src/ptbench/data/dataset.py
with
3 additions
and
3 deletions
src/ptbench/data/dataset.py
+
3
−
3
View file @
3da537d0
...
@@ -10,7 +10,7 @@ import torch.utils.data
...
@@ -10,7 +10,7 @@ import torch.utils.data
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
def
get_positive_weights
(
dataset
):
def
_
get_positive_weights
(
dataset
):
"""
Compute the positive weights of each class of the dataset to balance the
"""
Compute the positive weights of each class of the dataset to balance the
BCEWithLogitsLoss criterion.
BCEWithLogitsLoss criterion.
...
@@ -84,7 +84,7 @@ def reweight_BCEWithLogitsLoss(datamodule, model, criterion, criterion_valid):
...
@@ -84,7 +84,7 @@ def reweight_BCEWithLogitsLoss(datamodule, model, criterion, criterion_valid):
# Redefine a weighted criterion if possible
# Redefine a weighted criterion if possible
if
isinstance
(
criterion
,
torch
.
nn
.
BCEWithLogitsLoss
):
if
isinstance
(
criterion
,
torch
.
nn
.
BCEWithLogitsLoss
):
positive_weights
=
get_positive_weights
(
train_dataset
)
positive_weights
=
_
get_positive_weights
(
train_dataset
)
model
.
hparams
.
criterion
=
BCEWithLogitsLoss
(
pos_weight
=
positive_weights
)
model
.
hparams
.
criterion
=
BCEWithLogitsLoss
(
pos_weight
=
positive_weights
)
else
:
else
:
logger
.
warning
(
"
Weighted criterion not supported
"
)
logger
.
warning
(
"
Weighted criterion not supported
"
)
...
@@ -95,7 +95,7 @@ def reweight_BCEWithLogitsLoss(datamodule, model, criterion, criterion_valid):
...
@@ -95,7 +95,7 @@ def reweight_BCEWithLogitsLoss(datamodule, model, criterion, criterion_valid):
isinstance
(
criterion_valid
,
torch
.
nn
.
BCEWithLogitsLoss
)
isinstance
(
criterion_valid
,
torch
.
nn
.
BCEWithLogitsLoss
)
or
criterion_valid
is
None
or
criterion_valid
is
None
):
):
positive_weights
=
get_positive_weights
(
validation_dataset
)
positive_weights
=
_
get_positive_weights
(
validation_dataset
)
model
.
hparams
.
criterion_valid
=
BCEWithLogitsLoss
(
model
.
hparams
.
criterion_valid
=
BCEWithLogitsLoss
(
pos_weight
=
positive_weights
pos_weight
=
positive_weights
)
)
...
...
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