Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialize variable under variable scope? #24

Open
feng-1985 opened this issue Mar 19, 2019 · 0 comments
Open

initialize variable under variable scope? #24

feng-1985 opened this issue Mar 19, 2019 · 0 comments

Comments

@feng-1985
Copy link

feng-1985 commented Mar 19, 2019

The correct one:

    with tf.variable_scope(scope) as scope:
        w = tf.get_variable("weights", [x.shape[1], out_dim], initializer=tf.random_normal_initializer())
        b = tf.get_variable("biases", [out_dim], initializer=tf.constant_initializer(0.0))

The following code will raise the error: TypeError: Failed to convert object of type <class 'list'> to Tensor. Contents: [Dimension(100), 50]. Consider casting elements to a supported type.

    with tf.variable_scope(scope) as scope:
        w = tf.get_variable(initializer=tf.random_normal([x.shape[1], out_dim]), name='weights')
        b = tf.get_variable(initializer=tf.zeros([out_dim]), name='biases')

What's happened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant