Skip to content

Update class_weights to support list[float] #2707

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

robmarkcole
Copy link
Contributor

@robmarkcole robmarkcole commented Apr 7, 2025

Close #2060

Could be cleaner to deprecate tensor support, not sure if there is a process to this?

Validated with

trainer:
  max_epochs: 1
model:
  class_path: ClassificationTask
  init_args:
    model: 'resnet18'
    in_channels: 13
    num_classes: 10
    class_weights:
      - 1.0
      - 1.0
      - 1.0
      - 1.0
      - 1.0
      - 1.0
      - 1.0
      - 1.0
      - 1.0
      - 1.0
data:
  class_path: EuroSAT100DataModule
  init_args:
    batch_size: 8
  dict_kwargs:
    download: true

@github-actions github-actions bot added the trainers PyTorch Lightning trainers label Apr 7, 2025
@robmarkcole
Copy link
Contributor Author

Not sure why docs fail to build
image

@adamjstewart
Copy link
Collaborator

Could use https://docs.python.org/3/library/warnings.html#warnings.deprecated or explicitly raise https://docs.python.org/3/library/exceptions.html#DeprecationWarning for deprecation.

I'm not sure why the doc tests are failing either, but you're not the only PR with failing tests. Will try to investigate this later if it keeps happening.

@adamjstewart adamjstewart added this to the 0.8.0 milestone Apr 7, 2025
@adamjstewart
Copy link
Collaborator

Restarting the docs build fixed the other PR, hoping this is just a transient issue.

@robmarkcole
Copy link
Contributor Author

Hmm did this change break this test?

FAILED tests/models/test_copernicusfm.py::TestCopernicusFMBase::test_copernicusfm_variable - AssertionError: The input tensor is not within the configured range `[0.001, 510000000.0]`.

@adamjstewart
Copy link
Collaborator

Nope, this is because I used random numbers which are sometimes outside the valid range. Will submit a fix. If you rerun it should only fail 1% of the time.

@robmarkcole
Copy link
Contributor Author

Is there a rerun button somewhere? @adamjstewart

@adamjstewart
Copy link
Collaborator

Yes, just hit it. I don't think you have access, but I'm happy to rerun until CI is happy.

@robmarkcole
Copy link
Contributor Author

If you could - I dont see the button 🥹

@robmarkcole
Copy link
Contributor Author

@adamjstewart thoughts?

@adamjstewart
Copy link
Collaborator

Let's discuss more on #2060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
trainers PyTorch Lightning trainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

class_weights cannot be passed via config file as a tensor is expected
2 participants