You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When debugging the code, I realized that the betas repetition one line before is incorrect.
I believe that instead of betas = torch.tensor(betas).unsqueeze(1).repeat(1, sim_stack.shape[0])
it should be betas = torch.tensor(betas).unsqueeze(1).repeat(1, sim_stack.shape[1])
The shape of betas after this command should be (len(origin_betas), batch_size), and this is not what actually happens
(betas is already a column tensor, each element is power for each scale, so we want to repeat it with the amount of the batch size).
UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor)
The fix can be: sim_stack = sim_stack ** betas.to(device=sim_stack.device); cs_stack = cs_stack ** betas.to(device=cs_stack.device)
(since betas is already a tensor)
The text was updated successfully, but these errors were encountered:
MS-SSIM was used to measure two image tensors (BxCxHxW),
set reduction flag to None to get the losses without any reduction.
When I executed it, I got an error of size mismatch for this line:
https://github.com/Lightning-AI/metrics/blob/19355a9d2c51b3b39b311694d7b8e6856a73eae6/src/torchmetrics/functional/image/ssim.py#L407
When debugging the code, I realized that the betas repetition one line before is incorrect.
I believe that instead of
betas = torch.tensor(betas).unsqueeze(1).repeat(1, sim_stack.shape[0])
it should be
betas = torch.tensor(betas).unsqueeze(1).repeat(1, sim_stack.shape[1])
The shape of betas after this command should be (len(origin_betas), batch_size), and this is not what actually happens
(betas is already a column tensor, each element is power for each scale, so we want to repeat it with the amount of the batch size).
In addition, the next two lines raise warnings:
https://github.com/Lightning-AI/metrics/blob/19355a9d2c51b3b39b311694d7b8e6856a73eae6/src/torchmetrics/functional/image/ssim.py#L408
https://github.com/Lightning-AI/metrics/blob/19355a9d2c51b3b39b311694d7b8e6856a73eae6/src/torchmetrics/functional/image/ssim.py#L409
The fix can be:
sim_stack = sim_stack ** betas.to(device=sim_stack.device); cs_stack = cs_stack ** betas.to(device=cs_stack.device)
(since betas is already a tensor)
The text was updated successfully, but these errors were encountered: