GithubHelp home page GithubHelp logo

abhuse / polyloss-pytorch Goto Github PK

View Code? Open in Web Editor NEW
39.0 2.0 6.0 7 KB

Polyloss Pytorch Implementation

License: MIT License

Python 100.00%
deep-learning focal-loss loss-functions polyloss pytorch pytorch-implementation

polyloss-pytorch's People

Contributors

abhuse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

polyloss-pytorch's Issues

In the example, logits needs requires_grad=True

I'm using torch==1.11.0+cu113 and the example for Poly1 Cross-Entropy Loss throws an error RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn.

I just have to change line 7 to logits = torch.rand([batch_size, num_classes], requires_grad=True) for it to work.

using the weights for an imbalanced dataset

Hi,
Thanks a lot for providing a PyTorch implementation of PolyLoss.

I have a binary classification problem in which the class weights are as below:
class 0: 86.2% of 462 data points
class 1: 13.8% of 462 data points

When I use your loss with the same default parameters, all my validation predictions turn out to be 0, which is the majority class. Could you please show me how I should exactly set my criterion weight?

criterion = Poly1CrossEntropyLoss(num_classes=num_classes, reduction='mean')

About the label

Hello, my tensor size for the label is (batch, channel, H, W), how do I apply polyloss-focal

how to using poly Loss in object detection?

Could you please tell me how to change poly Loss if I use it in the object detection?
When I directly added poly loss to object detection, there was a error:
RuntimeError: Class values must be non-negatives
thanks in advance !

Error passing weights

Hi.
First of all, thanks for your great repo.

When I'm passing weights like this:

Poly1FocalLoss(num_classes=num_classes, 
                      reduction='mean',
                      weight=torch.tensor([0.1, 0.9]))

I get this error:
RuntimeError: The size of tensor a (256) must match the size of tensor b (2) at non-singleton dimension 3

B, C, H, W = 32, 2, 256, 256
Label is not one_hoted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.