3

I have Tensorflow network and I ported it in the Caffe format. All weights and algorithm is correct in Caffe and TF, I checked it several times.

But when I run both frameworks and compare their output layer-by-layer, small differences start to appear.

For example, if the result of the BatchNormalization at the one point in Caffe is 0.940091 then for TF at the same point it is 0.939559, so the difference is 0.0005319999999999769 . Very small but it gets amplified deeper in the network we go, and at the end values are very different. For Convolution difference is present also(-2.7540846 Caffe -2.7540843 TF) but it gets more noticeable after first BatchNormalization

I suppose it might be some internal difference and casting between some sort of FP16, FP32, FP64. Have no idea how TF handles conversion from python graph to C++ graph.

May be someone encountered same problem?

Il'ya Zhenin
  • 1,272
  • 2
  • 20
  • 31
  • It might be due to "floating point" numbers innacuracy, see this https://stackoverflow.com/questions/21895756/why-are-floating-point-numbers-inaccurate/21896128 – Mohamed Ali JAMAOUI Nov 15 '18 at 17:00
  • Caffe and Tensorflow have some differences in the implementation of the Batch norm layer. Caffe has divided it into a normalization layer followed by a scaling and bias layer. Another possible issue could be that Caffe expects the input shape with channels first [CxHxW] while Tensorflow wants [HxWxC] by default (see 'data_format' parameter) – Claes Rolen Nov 27 '18 at 20:08

0 Answers0