The results of tf.pow and torch.pow are different
I am trying to convert PyTorch scripts to Tensorflow.
This is the situation.
&gt;&gt;&gt; a=np.random.rand(500,500)
&gt;&gt;&gt; b=tf.pow(tf.constant(a, tf.float32),2)
&gt;&gt;&gt; c=torch.pow(torch.tensor(a, dtype=torch.float32),2)
&gt;&gt;&gt; np.sum(b.numpy() - c.numpy())
3.2455164e-06

I guess this difference is caused by floating-point representations between the two platform. (I am not sure)
Questions
Do I need to make them exactly the same with each other?
If so how do solve this problem?

As the comments already say, this is a common issue.
float32 only provides 6 digits of precision, which is what you see, since the difference is smaller than e-06. So as the comments already mentioned this is usual beheviour, if you need more precision you might want to use float64.
There was already a github issue regarding this &quot;problem&quot;, which was explained by albanD, who I took this information from.
