-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
Different behavior with float precision #4569
Comments
In my case, I use pycaffe to read, modify and write 'xxx.prototxt' file. Similar as metioned in this issue #3632, by setting the python protobuf's backend to python instead of the default cpp (I guess, please correct me if I am wrong), the float numbers in saved prototxt has the exactly same precision as expected: export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
python my_code.py @twmht Now I use python2.7.12 with protobuf 3.5.2, and this environment setting also works for the testing code you put in this issue. |
zchrissirhcz@ is right. We have a known issue for float type precision if it is using cpp extension: Python does not have C-style float , it only has a C-style double. Thus pure python is using double precision for both float and double field, cpp extension is using float precision for float field. |
Closing it for cleaning up. Feel free to reopen if you still have questions |
I found the difference when dealing with float point between different version of python-protobuf (2.6.1 vs 3.5.0.post1)
test.proto
python-protobuf 2.6.1
python-protobuf 3.5.0.post1
Not sure if it's a bug or not.
What makes the difference?
Thank you
The text was updated successfully, but these errors were encountered: