我试图用get_gradient_function()的tensorflow.nn.conv1d是这样的:import tensorflow as tffrom tensorflow.python.framework.ops import get_gradient_functiond = 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))我在倒数第二行收到以下错误。KeyError:“名称‘conv’指的是不在图中的操作。”
添加回答
举报
0/150
提交
取消