Skip to content

Fixed SSIM issue with variable batch#2562

Closed
vfdev-5 wants to merge 3 commits intomasterfrom
fix-2532-ssim-variable-batch
Closed

Fixed SSIM issue with variable batch#2562
vfdev-5 wants to merge 3 commits intomasterfrom
fix-2532-ssim-variable-batch

Conversation

@vfdev-5
Copy link
Copy Markdown
Collaborator

@vfdev-5 vfdev-5 commented May 3, 2022

Fixes #2532

Description:

  • Fixed SSIM issue with variable batch
  • Added a test
  • refactored previous test

Check list:

  • New tests are added (if a new feature is added)
  • New doc strings: description and/or example code are in RST format
  • Documentation is updated (if required)

@github-actions github-actions bot added the module: metrics Metrics module label May 3, 2022
@vfdev-5 vfdev-5 force-pushed the fix-2532-ssim-variable-batch branch from 1efa26a to 27b9c6f Compare May 3, 2022 00:39
@vfdev-5
Copy link
Copy Markdown
Collaborator Author

vfdev-5 commented May 3, 2022

@ydcjeff can you please review this PR. Thanks!

@vfdev-5 vfdev-5 requested a review from sdesrozis May 3, 2022 00:40
self._sum_of_batchwise_ssim += torch.mean(ssim_idx, (1, 2, 3), dtype=torch.float64).to(self._device)
batchwise_ssim = torch.mean(ssim_idx, (1, 2, 3), dtype=torch.float64).to(self._device)

if isinstance(self._sum_of_batchwise_ssim, float):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did'nt you just do:

self._sum_of_batchwise_ssim += torch.mean(ssim_idx, (1, 2, 3), dtype=torch.float64).to(self._device).sum()

while we havetorch.sum in compute?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ydcjeff any thoughts on this ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that could work.

@vfdev-5
Copy link
Copy Markdown
Collaborator Author

vfdev-5 commented May 4, 2022

Close in favor of #2563

@vfdev-5 vfdev-5 closed this May 4, 2022
@vfdev-5 vfdev-5 deleted the fix-2532-ssim-variable-batch branch May 4, 2022 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: metrics Metrics module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSIM update does not work for the last batch (if batch size is different)

3 participants