add test for exp and evaluate and fix the error
Where to find the function
PR #53
src/sympc/approximations/exponential.py
How to Reproduce
- Go to '...'
- Click on '...'
- Scroll down to '...'
- See error
Expected Behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
System Information
- OS: [e.g. iOS]
- OS Version: [e.g. 22]
- Language Version: [e.g. Python 3.7, Node 10.18.1]
- Package Manager Version: [e.g. Conda 4.6.1, NPM 6.14.1]
- Browser (if applicable): [e.g. Google Chrome]
- Browser Version (if applicable): [e.g. 81.0.4044.138]
Additional Context
Add any other context about the problem here.
I see that the problem comes from https://github.com/OpenMined/SyMPC/pull/53#discussion_r595302609. However, what exactly needs to be fixed. I have checked LaRiffle implementation and crypten implementation. It is exactly the same, so what must be fix?
I get that the error is to big, but maybe that is part of the aproximation and we should not use the exponential aproxiamation at all?
I see that the problem comes from #53 (comment). However, what exactly needs to be fixed. I have checked LaRiffle implementation and crypten implementation. It is exactly the same, so what must be fix?
I get that the error is to big, but maybe that is part of the aproximation and we should not use the exponential aproxiamation at all?
the results are flaky, if you can somehow improve the results that would be great!
Could a slower approximation work? The snippet below works but requires 10 seconds, instead of the 4 seconds required by the CrypTen of facebook. Reference: https://math.stackexchange.com/questions/55830/how-to-calculate-ex-with-a-standard-calculator
result = 1
# The number 26 comes from my own experimentation.
# This are the required rounds of approximation for an atol=1e-1 and numbers in a tensor between -10 and 10.
for i in range(26, 0, -1):
result = 1 + ((value / i) * result)
return result
There are other approximations, but they require functionalities that we do not have. For example, the floor operation over an MPCTensor or the private division, which is not yet implemented #20. I do not know if they are better approximations.
Nonetheless, approximations always comes with an error and in the case of e they tend to get really big with numbers far away from 0.
From my point of view, either we use this fast approximation at the cost of accuracy (~4 seconds) or we increase the accuracy and the time (~10 seconds).