-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VOS loss #47
VOS loss #47
Conversation
This reverts commit 5e8332c.
src/pytorch_ood/detector/vos.py
Outdated
|
||
def __init__(self, model: torch.nn.Module, weights_energy: torch.nn.Module): | ||
""" | ||
:param t: Temperature value :math:`T`. Default is 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
documentation inconsistent
src/pytorch_ood/detector/vos.py
Outdated
:param weights_energy: energy weights as torch.nn.module | ||
""" | ||
# Permutation depends on shape of logits | ||
tmp_scores_ = logits.permute(0, 2, 3, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this only work in segmentation settings?
src/pytorch_ood/loss/vos.py
Outdated
""" | ||
|
||
def __init__( | ||
self, logistic_regression, weights_energy, alpha=0.1, device="cuda:0", reduction="mean" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add type hints to parameters
examples/segmentation/street_vos.py
Outdated
# Create non-linear neural network functions | ||
phi = torch.nn.Linear(1, 2) | ||
weights_energy = torch.nn.Linear(num_classes, 1) | ||
if 'cuda' in device: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use to .to(device) method here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, these functions are linear
.vscode/settings.json | ||
.pre-commit-config.yaml | ||
.pre-commit-config.yaml | ||
.gitignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these files on the gitignore list?
src/pytorch_ood/loss/vos.py
Outdated
input_for_lr = torch.cat((energy_x_in, energy_v_out), -1) | ||
if "cuda" in self.device: | ||
labels_for_lr = torch.cat( | ||
(torch.ones(len(energy_x_in)).cuda(), torch.zeros(len(energy_v_out)).cuda()), -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use .to(device) function
src/pytorch_ood/loss/vos.py
Outdated
(torch.ones(len(energy_x_in)), torch.zeros(len(energy_v_out))), -1 | ||
) | ||
|
||
criterion = torch.nn.CrossEntropyLoss(reduction=self.reduction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please construct cross-entropy in constructor and not on each update
tests/detectors/test_vos.py
Outdated
|
||
import torch | ||
|
||
from src.pytorch_ood.detector import VOSBased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should fail since detector was renamed
tests/loss/test_vos.py
Outdated
|
||
class TestEnergyRegularization(unittest.TestCase): | ||
""" | ||
Test code for energy bounded learning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not up to date
src/pytorch_ood/detector/webo.py
Outdated
""" | ||
:param logits: logits given by your model | ||
""" | ||
return self.score(logits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will fail. please write some more tests.
add VOS loss, detector and segmentation example
pre-commit.config : update flake8 version to 5.0.2