Coder Social home page Coder Social logo

Scope names about prettytensor HOT 3 CLOSED

google avatar google commented on September 26, 2024
Scope names

from prettytensor.

Comments (3)

eiderman avatar eiderman commented on September 26, 2024

The new variable_scope is created when entering the method (it is buried in
the registration code, which is quite hairy to read).

The general way to share variables is to do the following pattern:

with tf.variable_scope('my_scope') as vs:
build_model()

with tf.variable_scope(vs, reuse=True): # could also enter 'my_scope'
build_model()

You can do this with any sub-part as well. If you want to share variables
across different layer types, you can supply the same name to the layer or
do something like the following:

Getting the shapes to line up is tricky, but possible.

x = single_patch.fully_connected(...)

y = full_image.conv2d(..., init = x.layer_parameters['weight'],
bias_init=x.layer_parameters['bias'])

On Sat, Apr 2, 2016 at 7:23 AM, Rasmus [email protected] wrote:

How do I not create create a scope for new variables? I've looked into the
code, but I simply cannot see how .variable() creates a new scope for the
variable.
This is undesired behavior for me, since I want to use the current scope
that I assigned with tf.variable_scope() to share some variables.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#18

from prettytensor.

rlrs avatar rlrs commented on September 26, 2024

I see, I am indeed sharing variables across different layer types - namely conv2d and deconv2d (which is a custom layer). Does initializing in that way actually share the variables though? It seems to me that once x_layer parameters are updated, y_layer won't be.

from prettytensor.

eiderman avatar eiderman commented on September 26, 2024

Yes it does. Under the hood it is just reusing the variables and the gradients are computed correctly.

from prettytensor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.