1

According to the code in: https://github.com/tensorflow/models/blob/master/tutorials/image/cifar10/cifar10.py, it happens that the same names are used for the tensors variables such as:

conv = tf.nn.conv2d(images, kernel, [1, 1, 1, 1], padding='SAME') # Under conv1, line: 208

and,

conv = tf.nn.conv2d(norm1, kernel, [1, 1, 1, 1], padding='SAME') # Under conv2, line 227

Therefore, why this is allowed in tensorflow? If for some reason, If I tried to say:

sess.run([conv], feed_dict{x: some_data})

Then which conv tensor we will be evaluated?

Second, if the conv tensor under CONV1 layer was referring to the tf.nn.conv2d operation. How could another conv tensor under CONV2 refer to the second tf.nn.conv2d operation? In other words, how they are treated separately?

Any help is much appreciated!!

2
  • 1
    I think, all of those are under different namescopes. Their TF names are different. So, they don't conflict Commented Jun 9, 2017 at 18:37
  • @hars, Yea I totally agree with you. But from the coding perspective, how is that possible? Commented Jun 9, 2017 at 19:28

1 Answer 1

2

for your question: latest "conv" is evaluated

For example:

import tensorflow as tf

a = tf.constant(5)
b = tf.constant(6)

c = tf.multiply(a,b)
print c
c = tf.multiply(c,b)
print c

sess = tf.Session()
c_val = sess.run(c)
print c_val

Output :

Tensor("Mul:0", shape=(), dtype=int32)
Tensor("Mul_1:0", shape=(), dtype=int32)
180

You can see TF names them differently. Whenever you call an TF operator, it creates a node independent of python variable name. But python variable name corresponds to latest tensor you used.

I hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.