Skip to content
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

Adding several loss (criteria) #609

Open
amirshamaei opened this issue Oct 9, 2023 · 1 comment
Open

Adding several loss (criteria) #609

amirshamaei opened this issue Oct 9, 2023 · 1 comment

Comments

@amirshamaei
Copy link

Hi, I am working on adopting H+PL template for MRI reconstruction. I need to have several loss functions. What is the best routine for adding them to a PL module?

Currently, I added this piece of code to init(). However, I believe it can be more efficient and general.

        criterion_1 : Callable = torch.nn.MSELoss,
        criterion_2:  Callable = None,
        criterion_3: Callable = None,
@amirshamaei
Copy link
Author

I made it a bit better as follows:

criterions: List = [torch.nn.MSELoss],

and config file:

criterions:
  - _target_: torch.nn.MSELoss
  - _target_: torch.nn.MSELoss

and the training step:

for criterion in self.criterions:
    loss += criterion(output_imgs, target_img)

I appreciate if you suggest a better approach

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

No branches or pull requests

1 participant