Wrong subtraction

I’ve got a trained model and noticed that it predicts different results depends on some third side code. I tried to make a minimal example. So, it load model takes first operation called ‘_minus_scalar0’, which should subtract 127.5 from the input matrix. But it is not! If you look at the screenshot, you can see that it subtracts 127.0 only. My notes:

  1. If I comment line 8, the code works correctly. I don’t understand why.
  2. I reproduced this issue on 3 computers from 4.

So, I can provide model and input image but it is possible that it will not reproduce.
My questions:

  1. What symbol operation corresponds to ‘_minus_scalar’? I checked broadcast_minus and broadcast_sub, these are not _minus_scalar operations.
  2. How can I fix incorrect subtraction?

your data is not float but int. Change your datatype of your input with .astype(‘float32’)

I checked datatype in line data = mx.nd.array(input_blob). It is float32. I think DataBatch wrappes with same datatype. If I misunderstood you, please, point to the particular line to change.

I would understand if you say that 127.5 converted to int, but it is not an input.

More over I checked:

    print(sym.infer_type(data='float32'))

and I’ve got ([<class 'numpy.float32'>], [<class 'numpy.float32'>], []). So, types should be fine for my input.