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

Possible mistake in your implementation? #7

Closed
kuoweilai opened this issue Jun 3, 2019 · 3 comments
Closed

Possible mistake in your implementation? #7

kuoweilai opened this issue Jun 3, 2019 · 3 comments

Comments

@kuoweilai
Copy link

In your implementation:
https://github.com/jorge-pessoa/pytorch-msssim/blob/master/pytorch_msssim/__init__.py
line 96:
output = torch.prod(pow1[:-1] * pow2[-1])
Should it be:
output = torch.prod(pow1[:-1]) * pow2[-1]
Otherwise the pow2 would be multiplied too many times?
Thanks!

@XiaotianM
Copy link

Hi, I find the official implement in tensorflow. The implementation is similar with this author's.
https://github.com/tensorflow/tensorflow/blob/r1.14/tensorflow/python/ops/image_ops_impl.py#L3143-L3267

@Ir1d
Copy link

Ir1d commented Oct 7, 2019

output = torch.prod(pow1[:-1] * pow2[-1])
I meet NaN during training on this line.
pytorch module tells me that Function 'ProdBackward0' returned nan values in its 0th output.
I've set normalize=True in the code, but nan still happens.
After changing to output = torch.prod(pow1[:-1]) * pow2[-1]
it turned out to Function 'MulBackward0' returned nan values in its 1th output.

@jorge-pessoa
Copy link
Owner

Hello,
I apologize for the delay in answering your question. As I understand from the official implementation, the product method (which is what is implemented in this repository) requires the multiplication of each value of the mcs array by the ssim of the last iteration of the SSIM calculation. See line 99 of msssim.m from https://ece.uwaterloo.ca/~z70wang/research/iwssim/ :

overall_mssim = prod(mcs_array(1:level-1).^weight(1:level-1))*(mssim_array(level).^weight(level));

Regarding your stability issues, I will be merging a different approach to ensure stability in the initial iterations which may help you (if you're still interested).

Thank you for your contributions. I will be closing this issue for now due to its age. If you still have any questions feel free to open a new one.

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

4 participants