i went through source code , gradient function implemented in python file
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/gradients_impl.py
but still couldn't find python api calculating gradients ? process ?
here's example code i'm taking gradient of loss function respect activations of last layer of network , passing tensorboard in form of single scalar value , histogram.
gradient_a = tf.gradients(loss, [0], [3]), [out_layer_a], name='gradient_position_a') tf.summary.scalar('mean_gradient_magnitude_a', tf.reduce_mean(tf.abs(self.gradient_a))) tf.summary.histogram('gradient_magnitude_a', gradient_a)
if want output gradient fetch gradient_a in call session.run([loss, gradient_a], feed_dict={...})
Comments
Post a Comment