Skip to content

Equivalent of with tf.name_scope(...)? #219

Open
@izaid

Description

@izaid

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions