def inception_arg_scope(
weight_decay=0.00004,
use_batch_norm=True,
batch_norm_decay=0.9997,
batch_norm_epsilon=0.001,
):
# Parameters for BatchNorm.
batch_norm_params = {
# Decay for the moving averages.
'decay': batch_norm_decay,
# epsilon to prevent 0s in variance.
'epsilon': batch_norm_epsilon,
}
if use_batch_norm:
normalizer_fn = layers.batch_norm
normalizer_params = batch_norm_params
else:
normalizer_fn = None
normalizer_params = {}
# Set weight_decay for weights in Conv and FC layers.
l2_regularizer = layers.l2_regularizer(weight_decay)
activation_fn = tf.nn.relu # tf.nn.elu
arg_scope_weights = arg_scope(
[layers.conv2d, layers.fully_connected],
weights_initializer=layers.variance_scaling_initializer(factor=1.0),
weights_regularizer=l2_regularizer
)
arg_scope_conv = arg_scope(
[layers.conv2d],
activation_fn=activation_fn,
normalizer_fn=normalizer_fn,
normalizer_params=normalizer_params
)
with arg_scope_weights, arg_scope_conv as arg_sc:
return arg_sc
build_inception_v4.py 文件源码
python
阅读 17
收藏 0
点赞 0
评论 0
评论列表
文章目录