Renaming a tensorflow variable

Is there any way to rename an existing tf.Variable without creating a new object?

Could you be more specific about the context?

What name are you trying to change? why?

1 Like

For some tensorflow variable like the following

import tensorflow as tf
a = tf.Variable([1,2,3], name = 'original_name')
print(a.name) # returns 'original_name:0'

Is there anyway to change the name of a from ‘original_name’ to some other name. My current workaround is:

a = tf.Variable(a, name = 'new_name')

I think that there aren’t other solutions as .name is a protected attr.

1 Like