hammerlab / flowdec

TensorFlow Deconvolution for Microscopy Data
Apache License 2.0
86 stars 26 forks source link

optimal padding that is more efficient than log2 #18

Closed VolkerH closed 5 years ago

VolkerH commented 5 years ago

this is a draft piull request to let you know I'm working on this so we don't duplicate effort by accident.

I found the log2 padding to be very wasteful with VRAM in worst cast scenarios, e.g. an input array of shape (129, 513, 513) will end up as (256, 1024, 1024) which is almost 8 times as large. In addition to wasting valuable VRAM this will also impact the other computations that have to process many more voxels.

Adding an option OPM_2357. Using a precomputed rainbow table (whether this is a good approach is open to debate but it is fast and has no dependencies).

Time to go to bed, will hopefully test tomorrow.

eric-czech commented 5 years ago

Thanks man! Sounds good to me and feel free to make that the default mode. That seems like a better choice since there was another issue or two from people hitting GPU memory issues immediately with so much padding.

VolkerH commented 5 years ago

Ok, this was more difficult than I thought ... I naively assumed I would be able to mix in some numpy. Now implemented the rainbow table lookup with tensorflow ops (however, with a less efficient search). Added some tests as well.

Some comments:

eric-czech commented 5 years ago

LGTM -- I'm not sure why that old test is failing in the build yet but I don't see how any of those changes would interfere with existing functionality so I'll patch it up. I think as a part of the fix for https://github.com/hammerlab/flowdec/issues/17, I'll want singleton dimensions to not get squeezed out (i.e. dropped), if I'm understanding you correctly, since that should make it easier to track spatial and batch dimensions.

Thanks again for putting this together!

VolkerH commented 5 years ago

Thanks for including the pull request

I think as a part of the fix for #17, I'll want singleton dimensions to not get squeezed out (i.e. dropped), if I'm understanding you correctly, since that should make it easier to track spatial and batch dimensions.

Ok, if I understand you correctly this might require a (simple) change to my code. My code will turn a singleton dimension into a "2"

(1, 128, 128) -> (2, 128, 128)

The simple fix is to include the number "1" as first list element of the rainbow table. In addition, this will also require a change to this test (change 2 to 1): https://github.com/hammerlab/flowdec/blob/6b92c32036ff6e3746c15268bb2902519fef0cc5/python/flowdec/fft_utils_test.py#L49