last day (15 days later) » 

2:33 PM
0
A: Tensorflow vs Tensorflow JS different results for floating point arithmetic computations

edkevekedThere might be a number of possibilities that can lead to the issue. 1- The ops used in python are not used in the same manner in both js and python. If that is the case, using exactly the same ops will get rid of the issue. 2- The tensors image might be read differently by the python library a...

 
Thank you for your reply, Actually the screenshot above is the comparison of the tensors on Docker and TF JS (on browser). The values are not the same , some at the precision level and some are totally different. The questions what I have are 1) what is the cause for this variation? 2) Is it possible to the get the tensor values same as on Docker by making any changes to the code ? 3) And is this difference is because of their architectures (GPU vs CPU)?
 
What are you calling tensorflow on docker ? Is it still the tfjs running on docker or is it a python code ?
 
It is a python code , I am trying to compare the output from Tensorflow on python which is running in a Docker container and Tensorflow JS and FYI I am not using canvas for the image , As my input is actually a DICOM image I am using parser in JS to get the pixel data and carrying out the next process
 
The answer explains what the issue might possibly be. Even if you're not using canvas for your image, tfjs uses canvas under the hood. Unless you try to compare the array image in both python and js, there is nothing more I can do to help
 
Yes I have compared the image array they were actually same. The results are diverging after I perform the computations on them.
 
2:33 PM
Can you add the python code as well to your question ?
 
I have added the python code to my question, please check.
 
I edited my question as well
 
Hi !
 
so you suggest to change the dtype while creating the tensorf3d?
sorry if this is already mentioned in your reply , Is it possible to get both the python and js results the same?
 
2:35 PM
Well, it will not necessary increase the precision. Because the dtype will at some point be transformed to float32 for the webgl as I already mentioned
But if precision is a must then you can consider changing the backend
using the cpu which will be slower
 
your asking me to do it in the JS?
 
yes
tf.setBackend('cpu') at the very beginning of the code
 
Okay will try that and see what sort variation will that bring to the values
also about the performance issue what you were mentioning
 
Well do not hesitate to upvote the answer. If you still have other questions, you can open other threads
 
Definitely I will do it and thanks for your time
 
2:41 PM
My pleasure. Until next time. Enjoy coding :)
 

last day (15 days later) »