Open robmarkcole opened 6 months ago
Care to make a PR to accept a list and convert to a tensor? If not then I can take it on this weekend.
You will get to it way before me!
For a bit of history, I added this in #1221 and it initially only supported lists. In #1413, @ntw-au modified this to support lists, numpy arrays, and torch tensors. Then in #1541, I modified it to only accept torch tensors. I agree we need a way to support class_weights
in a YAML file (and preferably also on the command line). If omegaconf supports this, we could also easily enable omegaconf as a parser: https://lightning.ai/docs/pytorch/stable/cli/lightning_cli_advanced_2.html#enable-variable-interpolation.
If you want to use it with hydra.utils.instantiate and omegaconf you would only need to do the following:
class_weights:
_target_: torch.tensor
data: [0.5, 0.5]
I haven't looked at the Lightning CLI in awhile but I wonder if it supports recursive instantiation like
class_weights:
class_path: torch.tensor
init_args:
data: [0.5, 0.5]
Description
Using the Lightning CLI we can train the SemanticSegmentationTask, but cannot use class_weights without an error. Solution is to accept a list if int in addition to tensor
Steps to reproduce
In Lightning CLI Yaml:
Will result in
Version
main