I tried to use get_gradient_function()
on tensorflow.nn.conv1d
like this:
import tensorflow as tf
from tensorflow.python.framework.ops import get_gradient_function
d = tf.constant([1, 0, 2, 3, 0, 1, 1], dtype=tf.float32, name='d')
k = tf.constant([2, 1, 3], dtype=tf.float32, name='k')
data = tf.reshape(d, [1, int(d.shape[0]), 1], name='data')
kernel = tf.reshape(k, [int(k.shape[0]), 1, 1], name='kernel')
conv = tf.nn.conv1d(data, kernel, 1, 'SAME', name='conv')
with tf.Session() as sess:
print (sess.run(conv))
op = tf.get_default_graph().get_operation_by_name('conv')
print(get_gradient_function(op))
I am getting the following error at the second to last line.
KeyError: "The name 'conv' refers to an Operation not in the graph."