Code Monkey home page Code Monkey logo

Comments (11)

askaradeniz avatar askaradeniz commented on June 3, 2024 3

I converted the current code of gerchberg-saxton method to torch with (f5e0a16).

The results may not match exactly because of the differences we noticed in #10 but they seem close to each other. These are the current reconstruction results from the numpy/cupy and torch versions with (edc9872):

numpy/cupy:
output_amplitude

torch:
output_amplitude_torch

from odak.

kaanaksit avatar kaanaksit commented on June 3, 2024 1

This routine is verified with a real holography setup. @askaradeniz in case you are interested in transferring this piece of code to learn module, the Numpy/Cupy version is ready.

from odak.

kaanaksit avatar kaanaksit commented on June 3, 2024 1

Well, actually, I think even if we don't fix it right now, having an issue is a reminder for the future.

from odak.

kaanaksit avatar kaanaksit commented on June 3, 2024

Gerchberg-Saxton phase retrieval method for Numpy/Cupy case is added with commit d2c4e3f .

A test routine can be found as in here. @askaradeniz please do not start conversion to torch until I verify this routine with a real holography setup.

from odak.

kaanaksit avatar kaanaksit commented on June 3, 2024

I suppose this concludes and closes this case.

from odak.

kaanaksit avatar kaanaksit commented on June 3, 2024

In fact, we may be able to overcome that tiny difference in results by comparing:

  • odak.wave.set_amplitude and odak.learn.set_amplitude ,
  • fftn and ifftn in torch with respect to fft2 and ifft in numpy, cupy.

I should also highlight that when @rongduo experimented the absolute maximum difference was 10, in her case she uses numpy. In my case it was 15, I use cupy. At the very least above two comparisons may help us understand further. Shall we initiate and examine those two at a separate issue @askaradeniz ? Would you be willing to take the lead on that?

from odak.

askaradeniz avatar askaradeniz commented on June 3, 2024

I suspect that the difference in absolute distance you see is due to the randomization of the input field.
https://github.com/kunguz/odak/blob/edc987256afe6bfad16aae4031e047a717999b60/test/test_learn_beam_propagation.py#L73

Ofcourse, I can take the lead about the matching issue.

from odak.

kaanaksit avatar kaanaksit commented on June 3, 2024

Makes perfect sense. Do we get the same results without it? If so no additional issue is needed, all we need to do is to comment that line.

But wait, I thought torch and numpy comparison uses the same original field, no?
https://github.com/kunguz/odak/blob/edc987256afe6bfad16aae4031e047a717999b60/test/test_learn_beam_propagation.py#L79

from odak.

askaradeniz avatar askaradeniz commented on June 3, 2024

I mean they can give different absolute difference everytime we run the test case because of the randomization. So, it is normal to have different absolute differences at each run. However, our problem is that 10 or 15 difference should be much smaller as both of them use the same field.

from odak.

askaradeniz avatar askaradeniz commented on June 3, 2024

Maybe we can just leave it as is and reopen the issue when someone needs more precise matching. @kunguz Would it be OK?

from odak.

kaanaksit avatar kaanaksit commented on June 3, 2024

Sure, but we don't have an understanding at the moment on where does the difference come from. U1 returns same for example but right after final fft2 results diverges. Analysing set_amplitude should be straight forward.

from odak.

Related Issues (20)

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.