TensorFlow.jl icon indicating copy to clipboard operation
TensorFlow.jl copied to clipboard

Equivalent of `with tf.name_scope(...)`?

Open izaid opened this issue 8 years ago • 1 comments

Hi! These bindings to TensorFlow are great, really enjoying them.

I was just wondering what the proper equivalent of tf.name_scope(...) is in TensorFlow.jl. In TensorFlow.py, I might do something like

conv_net = tf.placeholder(tf.float32)

with tf.name_scope('my_op') as scope:
            weights = tf.Variable(..., name="weights")
            conv = tf.nn.conv2d(conv_net, weights, ...)

This gives me a named node "my_op" with "weights" as a variable inside that node scope. How can I achieve this in TensorFlow.jl? From experimenting, it seems something like this almost does it:

 with_op_name("my_op") do
     variable_scope("my_op") do
         weights = get_variable("weights", size, Float32)
         conv = nn.conv2d(conv_net, weights, ...)
      end
 end

Is the above supposed to be the correct way? My only issue with the above is that it seems to generate new names for all reused functions, e.g. if I add two tensors the operation is called "add_2" the second time I call variable_scope.

izaid avatar May 22 '17 17:05 izaid

I am also confused by this. The scoping works for some things and not for others. I suspect it is just not fully fleshed out yet.

Evizero avatar Sep 18 '17 11:09 Evizero