codecamp

TensorFlow函数:tf.variance_scaling_initializer

tf.variance_scaling_initializer函数

variance_scaling_initializer类

别名:

  • 类 tf.initializers.variance_scaling
  • 类 tf.keras.initializers.VarianceScaling
  • 类 tf.variance_scaling_initializer

定义在:tensorflow/python/ops/init_ops.py

初始化程序能够使其规模适应权重张量的形状.

使用distribution="normal",样本从以0为中心的截断正态分布中抽取;使用stddev = sqrt(scale / n),其中n为:

  • 如果mode =“fan_in”,n为权重张量中输入单元的数量;
  • 如果mode =“fan_out”,n为输出单元的数量;
  • 如果mode =“fan_avg”,n为平均输入的数量和输出单元的数量.

使用distribution="uniform",样本从[-limit, limit],其中limit = sqrt(3 * scale / n),内的均匀分布中抽取.

参数:

  • scale:比例因子(正浮点数).
  • mode:为“fan_in”、“fan_out”以及“fan_avg”中的一个.
  • distribution:随机分配使用,“normal”,“uniform”其中之一.
  • seed:一个Python的整数用于创建随机种子;查看tf.set_random_seed的行为.
  • dtype:数据类型,仅支持浮点类型.

可能引发的异常:

  • ValueError:如果“scale”,“mode”或“distribution”参数的值无效.

方法

__init__

__init__(
    scale=1.0,
    mode='fan_in',
    distribution='normal',
    seed=None,
    dtype=tf.float32
)

__call__

__call__(
    shape,
    dtype=None,
    partition_info=None
)

from_config

from_config(
    cls,
    config
)

从配置字典中实例化一个初始化程序.

如下示例:

initializer = RandomUniform(-1, 1)
config = initializer.get_config()
initializer = RandomUniform.from_config(config)

参数:

  • config:一个Python的字典,它通常是get_config的输出.

返回值:

返回一个初始化实例.

get_config

get_config()
TensorFlow函数:tf.variable_scope
TensorFlow函数:tf.VarLenFeature
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }