Coder Social home page Coder Social logo

ms_ssim_pytorch's Issues

Add dynamic channel expansion.

Hello. I have been looking at the current implementation and I have found that it uses .repeat() on CPU.

However, I would like to propose using .expand() inside the ssim() function. This has several advantages.

First, this will significantly reduce the amount of data passing from CPU to GPU, which is a major bottleneck in CUDA programming. .repeat() copies data. .expand() does not copy data. So there is not much overhead in using .expand() after transferring the kernel to GPU.

Second, this will allow one to remove the 'channel' parameter from SSIM(), which will remove an unnecessary parameter.

实际运行中,容易内存爆掉

感谢大佬的杰出贡献,速度上确实提升不少。但是在实际运行的时候,我遇到了一些问题。我在我的网络中插入您的SSIMloss,运行代码后,每次都在运行到一半的时候(开始可以运行),内存直接占满爆掉。无论是服务器还是自己的电脑,都是这样。在修改了dataloader的各种参数后,还是出现这种情况。后来我将SSIMloss改为您代码中的loss3,这种情况就没有了。我不太了解您代码的运行情况,但是在实际运行中确实遇到了这个问题,所以向您反馈一下,不知道原因在哪里。

try clamp_min(0.001) to avoid nan when backward() in early step

thanks for your great effort to speed up the msssim.

I found nan when backward in very early iter when training. this is because

cs**a => 1/cx**(a-1) when backward

in the early step, the cs is very small, so 1/cs is inf.

I noticed that you use clamp_min(0.) in the msssim.py. I think replace 0 with 0.00001 will fix the nan problem when early train.


        ssim_val = ssim_val.clamp_min(0.0001) # avoid 1/x**(a-1) to be inf when x is very close to zero
        cs = cs.clamp_min(0.0001)

please correct me if i am wrong

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.