Skip to content Skip to sidebar Skip to footer

Different Outcomes When Using Tf.variable() And Tf.get_variable()

I'm trying to get familiar with TensorFlow framework from this site by playing around with Linear Regression (LR). The source code for LR can be found here, with the name 03_linear

Solution 1:

tf.Variable accepts an initial value upon creation (a constant), this explains deterministic results when you use it.

tf.get_variable is slightly different: it has an initializer argument, by default None, which is interpreted like this:

If initializer is None (the default), the default initializer passed in the variable scope will be used. If that one is None too, a glorot_uniform_initializer will be used.

Since you didn't pass an initializer, the variable got uniform random initial value.

Post a Comment for "Different Outcomes When Using Tf.variable() And Tf.get_variable()"