Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

tf.test.compute_gradient returns unexpected numerical Jacobian

I use Tensorflow 1.7.0, python 3.6.

I created an Autoencoder that accepts arrays (n, 10) and compresses them into arrays (n, 2). The hidden layer has two neurons.

After the training phase is over, I would like to get the Jacobian matrix for every single record. So i reload the autoencoder saved.

I take: x = a single array (1.10) y = a single array (1,2)

checkp = tf.train.get_checkpoint_state(self.modelpath)
self.saver = tf.train.Saver()
self.saver.restore(sess, checkp.model_checkpoint_path)

dataenc = sess.run(fetches=[self.enc], feed_dict={self.in_: row, self.targets_: row})

analytical, numerical = tf.test.compute_gradient(self.in_, (1, 10), self.enc, (1, 2))

self.in_ and self.enc are two tensor with respectively x and y.

My problem is:

if i pass the same array x to the function (in the same execution) --> the numerical Jacobian changes value.

if i relanch my script but i pass a different array x --> the numerical Jacobian is the same as the previous one.

It seems dependent on the number of invocations of the function.

Thanks in advance.

Comments