tf.gradients returns None for gradient with self for integer variable?

I was playing around with tf.gradients and got gradients as None for the below code:
>>> x = tf.Variable(10) # integer type >>> tf.gradients(x,x) [None] >>> sess.run(tf.gradients(x,x)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1137, in _run self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 471, in __init__ self._fetch_mapper = _FetchMapper.for_fetch(fetches) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 261, in for_fetch return _ListFetchMapper(fetch) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 370, in __init__ self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in fetches] File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 258, in for_fetch type(fetch))) TypeError: Fetch argument None has invalid type <type 'NoneType'>
>>> x = tf.Variable(10.0) # float type >>> tf.gradients(x,x) [<tf.Tensor 'gradients_6/Fill:0' shape=() dtype=float32>] >>> sess.run(tf.gradients(x,x)) [1.0]

The environment is Python 2.7 with tensorflow 1.12
I'm not able to understand why this happens. shouldn't it be the same for both the cases of float and int?

Write your answer...

It's not the same without you

Join the community to find out what other Ednsquare users are discussing, debating and creating.