karl_TUM karl_TUM - 1 year ago 141
Python Question

what is the difference between var.op.name and var.name in tensorflow?

I have one point confusing. Here is the example code:

opt = tf.train.GradientDescentOptimizer(1e-4)
grads_and_vars = opt.compute_gradients(total_loss)
for grad, var in grads_and_vars:

the output is:
conv1/filt conv1/bias

and when I change

the output is:
conv1/filt:0 conv1/bias:0

What is the difference between
and what does

Answer Source

"op.name" is the name of the Operation, while "var.name" is the name of the Tensor. Operation is the thing that allocates memory, and produces outputs available on endpoints :0, :1, etc. Tensor is an output of an operation, so it corresponds to some endpoint. In this case conv1/filt is the Variable Operation that is in charge of the memory, and conv1/filt:0 is the first endpoint of that operation. The practical difference is that conv1/filt:0 is what you can fetch to get the value, ie sess.run(["conv1/filt:0"])

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download