In TensorFlow, how can I look at the batch normalization parameters?
I'm using a tf.layers.batch_normalization
layer in my network. As you may know, batch normalization employs trainable parameters gamma and beta to each unit u_i in this layer, to choose its own standard deviation and mean across u_i(x) for various inputs x. Typically gamma is initialized to 1 and beta to 0.
I'm interested in peeking at the values of gamma and beta that are being learned at various units, to collect statistics about where they tend to end up after the network trains. How can I peek at their current values during each training instance?
tensorflow machine-learning neural-network python-3.6
add a comment |
I'm using a tf.layers.batch_normalization
layer in my network. As you may know, batch normalization employs trainable parameters gamma and beta to each unit u_i in this layer, to choose its own standard deviation and mean across u_i(x) for various inputs x. Typically gamma is initialized to 1 and beta to 0.
I'm interested in peeking at the values of gamma and beta that are being learned at various units, to collect statistics about where they tend to end up after the network trains. How can I peek at their current values during each training instance?
tensorflow machine-learning neural-network python-3.6
add a comment |
I'm using a tf.layers.batch_normalization
layer in my network. As you may know, batch normalization employs trainable parameters gamma and beta to each unit u_i in this layer, to choose its own standard deviation and mean across u_i(x) for various inputs x. Typically gamma is initialized to 1 and beta to 0.
I'm interested in peeking at the values of gamma and beta that are being learned at various units, to collect statistics about where they tend to end up after the network trains. How can I peek at their current values during each training instance?
tensorflow machine-learning neural-network python-3.6
I'm using a tf.layers.batch_normalization
layer in my network. As you may know, batch normalization employs trainable parameters gamma and beta to each unit u_i in this layer, to choose its own standard deviation and mean across u_i(x) for various inputs x. Typically gamma is initialized to 1 and beta to 0.
I'm interested in peeking at the values of gamma and beta that are being learned at various units, to collect statistics about where they tend to end up after the network trains. How can I peek at their current values during each training instance?
tensorflow machine-learning neural-network python-3.6
tensorflow machine-learning neural-network python-3.6
asked Nov 13 '18 at 13:46
Eric AuldEric Auld
17313
17313
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You could get all the variables inside the scope of the batch normalization layer and print them. Example:
import tensorflow as tf
tf.reset_default_graph()
x = tf.constant(3.0, shape=(3,))
x = tf.layers.batch_normalization(x)
print(x.name) # batch_normalization/batchnorm/add_1:0
variables = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES,
scope='batch_normalization')
print(variables)
#[<tf.Variable 'batch_normalization/gamma:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/beta:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_mean:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_variance:0' shape=(3,) dtype=float32_ref>]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
gamma = sess.run(variables[0])
print(gamma) # [1. 1. 1.]
Thank you! I gather that the scopebatch_normalization
is added automatically by the layer?
– Eric Auld
Nov 14 '18 at 19:00
Yes, that's correct.
– Vlad-HC
Nov 14 '18 at 19:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53282439%2fin-tensorflow-how-can-i-look-at-the-batch-normalization-parameters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could get all the variables inside the scope of the batch normalization layer and print them. Example:
import tensorflow as tf
tf.reset_default_graph()
x = tf.constant(3.0, shape=(3,))
x = tf.layers.batch_normalization(x)
print(x.name) # batch_normalization/batchnorm/add_1:0
variables = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES,
scope='batch_normalization')
print(variables)
#[<tf.Variable 'batch_normalization/gamma:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/beta:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_mean:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_variance:0' shape=(3,) dtype=float32_ref>]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
gamma = sess.run(variables[0])
print(gamma) # [1. 1. 1.]
Thank you! I gather that the scopebatch_normalization
is added automatically by the layer?
– Eric Auld
Nov 14 '18 at 19:00
Yes, that's correct.
– Vlad-HC
Nov 14 '18 at 19:31
add a comment |
You could get all the variables inside the scope of the batch normalization layer and print them. Example:
import tensorflow as tf
tf.reset_default_graph()
x = tf.constant(3.0, shape=(3,))
x = tf.layers.batch_normalization(x)
print(x.name) # batch_normalization/batchnorm/add_1:0
variables = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES,
scope='batch_normalization')
print(variables)
#[<tf.Variable 'batch_normalization/gamma:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/beta:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_mean:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_variance:0' shape=(3,) dtype=float32_ref>]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
gamma = sess.run(variables[0])
print(gamma) # [1. 1. 1.]
Thank you! I gather that the scopebatch_normalization
is added automatically by the layer?
– Eric Auld
Nov 14 '18 at 19:00
Yes, that's correct.
– Vlad-HC
Nov 14 '18 at 19:31
add a comment |
You could get all the variables inside the scope of the batch normalization layer and print them. Example:
import tensorflow as tf
tf.reset_default_graph()
x = tf.constant(3.0, shape=(3,))
x = tf.layers.batch_normalization(x)
print(x.name) # batch_normalization/batchnorm/add_1:0
variables = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES,
scope='batch_normalization')
print(variables)
#[<tf.Variable 'batch_normalization/gamma:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/beta:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_mean:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_variance:0' shape=(3,) dtype=float32_ref>]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
gamma = sess.run(variables[0])
print(gamma) # [1. 1. 1.]
You could get all the variables inside the scope of the batch normalization layer and print them. Example:
import tensorflow as tf
tf.reset_default_graph()
x = tf.constant(3.0, shape=(3,))
x = tf.layers.batch_normalization(x)
print(x.name) # batch_normalization/batchnorm/add_1:0
variables = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES,
scope='batch_normalization')
print(variables)
#[<tf.Variable 'batch_normalization/gamma:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/beta:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_mean:0' shape=(3,) dtype=float32_ref>,
# <tf.Variable 'batch_normalization/moving_variance:0' shape=(3,) dtype=float32_ref>]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
gamma = sess.run(variables[0])
print(gamma) # [1. 1. 1.]
answered Nov 13 '18 at 14:53
Vlad-HCVlad-HC
950915
950915
Thank you! I gather that the scopebatch_normalization
is added automatically by the layer?
– Eric Auld
Nov 14 '18 at 19:00
Yes, that's correct.
– Vlad-HC
Nov 14 '18 at 19:31
add a comment |
Thank you! I gather that the scopebatch_normalization
is added automatically by the layer?
– Eric Auld
Nov 14 '18 at 19:00
Yes, that's correct.
– Vlad-HC
Nov 14 '18 at 19:31
Thank you! I gather that the scope
batch_normalization
is added automatically by the layer?– Eric Auld
Nov 14 '18 at 19:00
Thank you! I gather that the scope
batch_normalization
is added automatically by the layer?– Eric Auld
Nov 14 '18 at 19:00
Yes, that's correct.
– Vlad-HC
Nov 14 '18 at 19:31
Yes, that's correct.
– Vlad-HC
Nov 14 '18 at 19:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53282439%2fin-tensorflow-how-can-i-look-at-the-batch-normalization-parameters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown