conv4d icon indicating copy to clipboard operation
conv4d copied to clipboard

Python 3 compatibility

Open dansontong opened this issue 7 years ago • 3 comments

it's a nice job to implement conv4d function. variable 'out_frame' should be turn int. but why conv4d's result is not the same as manually result?

here is my run result: conv4d at (0, 0, 0, 0): -113.075 manually computed value at (0, 0, 0, 0): 10.4666204602 conv4d at (4, 4, 4, 4): -64.2123 manually computed value at (4, 4, 4, 4): -64.2123170346 conv4d at (0, 0, 0, 0): 1355.0 manually computed value at (0, 0, 0, 0): 929.0 conv4d at (5, 5, 5, 5): 4006.0 manually computed value at (5, 5, 5, 5): 4006.0 conv4d at (9, 10, 11, 12): 1016.0 manually computed value at (9, 10, 11, 12): 1016.0

dansontong avatar Jul 12 '18 02:07 dansontong

especially the second case ( 3th,4th,5th result ). kernel_initializer is constant 1. even though kernel was flipped in function conv4d, the result should be the same. anyone can help?

dansontong avatar Jul 20 '18 11:07 dansontong

done! variable 'out_frame' should be turn int by this way: out_frame = j - (i - int(l_k/2)) - int((l_i - l_o)/2) # flipped, key point: add different signal by differnt time step(like a stairs), # refer to: www.zhihu.com/question/22298352, answer of 张俊博(zhangjunbo)

and then conv4d goes well, results: conv4d at (0, 0, 0, 0): 159.174 manually computed value at (0, 0, 0, 0): 159.174363315 conv4d at (4, 4, 4, 4): 116.684 manually computed value at (4, 4, 4, 4): 116.683920667 conv4d at (0, 0, 0, 0): 791.0 manually computed value at (0, 0, 0, 0): 791.0 conv4d at (5, 5, 5, 5): 3935.0 manually computed value at (5, 5, 5, 5): 3935.0 conv4d at (9, 10, 11, 12): 669.0 manually computed value at (9, 10, 11, 12): 669.0

dansontong avatar Jul 21 '18 02:07 dansontong

Thanks @dansontong for spotting that issue. I believe you ran into it using python 3, where the semantics of the / operator changed (I only tested with python 2). I believe the proper way to handle that is to from __future__ import division, and then use the // operator instead of /.

Do you want to make a pull request for the fix?

funkey avatar Aug 01 '18 07:08 funkey