yiyixuxu / polyloss-pytorch Goto Github PK
View Code? Open in Web Editor NEWImplementing PolyLoss in Pytorch
Implementing PolyLoss in Pytorch
Hello,
While making one-hot encoding of labels. I got these types of errors at scatter PyTorch.
/opt/conda/conda-bld/pytorch_1646756402876/work/aten/src/ATen/native/cuda/ScatterGatherKernel.cu:276: operator(): block: [66,0,0], thread: [5,0,0] Assertion idx_dim >= 0 && idx_dim < index_size && "index out of bounds"
failed.
Note : My labels is a mask with classes=2 and ignore_index=255 (label.unique()=[0,1,255]
torch.nn.CrossEntropyLoss
expect you to pass raw, unnormalized logit, however, either logit or probability is passing into cross entropy loss. If the probability is used will lead to unintended result.
README example is not reproducible as target_idx
does not exist.
import torch
from PolyLoss import to_one_hot, PolyLoss
# Example of target in one-hot encoded format
loss = PolyLoss(softmax=True)
B, C, H, W = 2, 5, 3, 3
input = torch.rand(B, C, H, W, requires_grad=True)
target = torch.randint(low=0, high=C - 1, size=(B, H, W)).long()
target = to_one_hot(target_idx[:, None, ...], num_classes=C)
output = loss(input, target)
output.backward()
...
Traceback (most recent call last):
File "/Users/glennjocher/PycharmProjects/yolov5-pro/venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3457, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-0534d4642825>", line 8, in <module>
target = to_one_hot(target_idx[:, None, ...], num_classes=C)
NameError: name 'target_idx' is not defined
Hello, Thank you for your work. I want to use the poly loss for image segmentation. I have input [B,C,H,W] and mask as [B,H,W]. I have ignore_indexes too in masks. how can I use your provided loss function correctly? Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.