问题描述
在 TensorFlow 中,批量归一化参数包括 beta
、gamma
、moving mean
和 moving variance
.但是,为了初始化这些参数,tf.contrib.layers.batch_norm(*args, **kwargs)
中只有一个参数叫做 param_initializers
,根据它包含的文档beta
、gamma
、moving mean
和 moving variance
的可选初始化器.
In TensorFlow, batch normalization parameters include beta
, gamma
, moving mean
, and moving variance
. However, for initializing these parameters there is only one argument in tf.contrib.layers.batch_norm(*args, **kwargs)
called param_initializers
which according to the documents it contains optional initializers for beta
, gamma
, moving mean
and moving variance
.
我们如何使用param_initializers
来初始化这些参数?
How can we use param_initializers
to initialize these parameters?
推荐答案
这里是如何使用 使用 Tensorflow 1.0 进行批量标准化:
import tensorflow as tf
batch_normalization = tf.layers.batch_normalization
... (define the network)
net = batch_normalization(net)
... (define the network)
如果你想设置参数,就这样做:
If you want to set parameters, just do it like this:
net = batch_normalization(net,
beta_initializer=tf.zeros_initializer(),
moving_variance_initializer=tf.ones_initializer())
*args, **kwargs
这是传递任意多个非关键字参数args
和任意多个关键字参数kwargs
的python方式.例如:
*args, **kwargs
This is the python way to pass arbitrary many non-keyword arguments args
and arbitrary many keyword arguments kwargs
. For example:
def test(*args, **kwargs):
print("#" * 80)
print(args)
print("#" * 80)
print(kwargs)
test(1, 2, 42, 3.141, 'foo', a=7, b=3, c='bla')
给予
################################################################################
(1, 2, 42, 3.141, 'foo')
################################################################################
{'a': 7, 'c': 'bla', 'b': 3}
这篇关于TensorFlow 中的批量归一化初始值设定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!