Can I return variables in addition to the gradient using tf.registergradient

47 Views Asked by At

I have a question about the tf.registergradient operation

I am using @tf.registergradient to make custom changes to the tensorflow gradients. Note: I am not modifying only the delta part of the backpopogated gradients. This is working fine. But now I want to save the variables that I am modifying, both before and after the modifications, so that I can analyse them later after I am done training. However I am not sure how to do this. Here is the code snippet

@tf.RegisterGradient("CustomModGrad")

def noise_delta(unused_op, delta):
noiz = tf.random_normal(shape=tf.shape(grad), stddev=sigma_value)
delta = tf.add(delta,noiz)
return delta

I want to store the noiz and delta variables so that I can analyze them later. How do I do this? Thank You!

0

There are 0 best solutions below