Giter Club home page Giter Club logo

Comments (3)

HuguesTHOMAS avatar HuguesTHOMAS commented on September 6, 2024 3

Hi @dsheacanopy,

This is an interesting question. There are many ways to help minority classes. In my current implementation, you have two options (that you can use separately or combine).

The first is using the option use_potentials=False when creating the S3DISDataset. For S3DIS, I have designed two dataloader strategies.

  • use_potentials=True : this strategy uses values on every points that I call potentials, when I pick an input sphere in the dataset, I update the potential value by incrementing them. And the next sphere will be picked at the minimum of potentials. This strategy ensure a geometric consistency in the sphere picking. We pick every part of the point cloud the same amount of time, compared to a random picking, where in practice, some part of the point cloud could actually never be picked, especially if they have low density.
  • use_potentials=False: This strategy is similar to the balanced_class=True in SemanticKitti.py. It is a random picking of the input sphere, but balanced by class. If the epoch need N sphere, we choose N/C sphere centered on a point of each class (where C is the number of classes). This strategy ensures that the network sees the minority class more often.
    The second strategy is the one you are looking for, but remember it will be affected by varying densities as it remains a random picking.

The second option for you is to use the parameter class_w, which controls the weight of each class in the loss. There is an example where I try using that here:

# sqrt(Inverse of proportion * 100)
# class_w = [1.430, 14.142, 9.535, 4.226, 5.270, 11.952, 12.910, 10.541, 0.719,
# 2.377, 0.886, 3.863, 0.869, 1.209, 0.594, 3.780, 1.129, 5.505, 11.180]

If you use the first option, you can find a function to compute the class proportion as seen by your loss here:
def debug_class_w(dataset, loader):

Don't hesitate to share your results here. I am curious to know if you manage to predict your minority class and how. In my case, class_w had nearly no effect, and the first option was the one which help the most.

Best,
Hugues

from kpconv-pytorch.

dsheacanopy avatar dsheacanopy commented on September 6, 2024

Thank you so much for your help! I was able to get it to make predictions on the minority class by using both approaches simultaneously. I did have some success with each approach by itself, but it appears that both together seem to have produced the best improvement in results.

I will close this issue since the core problem is resolved, but I did have to make a couple small changes on my side to get it to run. In particular:

https://github.com/HuguesTHOMAS/KPConv-PyTorch/blob/master/datasets/S3DIS.py#L513

https://github.com/HuguesTHOMAS/KPConv-PyTorch/blob/master/utils/trainer.py#L587

These were raising an IndexError when setting use_potentials=False so I ended up just breaking on the exception. I don't know if this is the preferred workaround, or if that should have been happening at all, but it appears to have worked for me.

Thanks again!

from kpconv-pytorch.

G-Anjanappa avatar G-Anjanappa commented on September 6, 2024

Hi @dsheacanopy

I am trying to do something similar. Could you please let me know how you got to make predictions for the minority classes?
This would really be helpful.

Thank you in advance.

from kpconv-pytorch.

Related Issues (20)

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.