The matrix multiplication values vary when tensorflow is run in eager mode vs graph mode
The code flow is different for eager and non-eager executions within tensorflow. But the values must match ideally, which is not.
Eager execution:
import tensorflow as tf
from tensorflow.python.ops import gen_math_ops
import numpy as np
tf.enable_eager_execution()
dZ = np.array([[ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -0.9, 0.1, 0.1, 0.1]])
FC_W = np.array([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]])
import pdb
pdb.set_trace()
a = gen_math_ops.mat_mul(dZ, FC_W, False, True)
print(a)
Output of eager execution: [[-2.77555756e-17 -2.77555756e-17 -2.77555756e-17]
Graph execution:
import tensorflow as tf
from tensorflow.python.ops import gen_math_ops
import numpy as np
dZ = np.array([[ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -0.9, 0.1, 0.1, 0.1]])
FC_W = np.array([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]])
a = gen_math_ops.mat_mul(dZ, FC_W, False, True)
sess = tf.InteractiveSession()
print(str(sess.run(a)))
Output of graph execution: [[-5.55111512e-17 -5.55111512e-17 -5.55111512e-17]]
Isn't this too much difference in output, between the two modes, for a simple matrix multiplication? (Although it is e-17)