• slim.variance_scaling_initializer()


    参考  slim.l2_regularizer() - 云+社区 - 腾讯云

    参考 slim.variance_scaling_initializer() - 云+社区 - 腾讯云

    1. def xavier_initializer(uniform=True, seed=None, dtype=dtypes.float32):
    2. """Returns an initializer performing "Xavier" initialization for weights.
    3. This function implements the weight initialization from:
    4. Xavier Glorot and Yoshua Bengio (2010):
    5. [Understanding the difficulty of training deep feedforward neural
    6. networks. International conference on artificial intelligence and
    7. statistics.](
    8. http://www.jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf)
    9. This initializer is designed to keep the scale of the gradients roughly the
    10. same in all layers. In uniform distribution this ends up being the range:
    11. `x = sqrt(6. / (in + out)); [-x, x]` and for normal distribution a standard
    12. deviation of `sqrt(2. / (in + out))` is used.
    13. Args:
    14. uniform: Whether to use uniform or normal distributed random initialization.
    15. seed: A Python integer. Used to create random seeds. See
    16. `tf.set_random_seed` for behavior.
    17. dtype: The data type. Only floating point types are supported.
    18. Returns:
    19. An initializer for a weight matrix.
    20. Raises:
    21. ValueError: if `dtype` is not a floating point type.
    22. TypeError: if `mode` is not in ['FAN_IN', 'FAN_OUT', 'FAN_AVG'].
    23. """
    24. if not dtype.is_floating:
    25. raise TypeError('Cannot create initializer for non-floating point type.')
    26. if mode not in ['FAN_IN', 'FAN_OUT', 'FAN_AVG']:
    27. raise TypeError('Unknown mode %s [FAN_IN, FAN_OUT, FAN_AVG]', mode)

    返回对权重执行“Xavier”初始化的初始化器。此函数实现权重初始化,从:

    Xavier Glorot和yobengio(2010):[了解深度前馈神经网络训练的难点]。(http://www.jmlr.org/programedings/papers/v9/glorot10a/glorot10a.pdf)

    这个初始化器的设计目的是在所有层中保持梯度的比例大致相同。在均匀分布中,这个范围是' x = sqrt(6。/ (in + out);正态分布的标准差为√2。/ (in + out))’。

    参数:

    • factor:浮动。一个乘法因素
    • mode:字符串。“FAN_IN”、“FAN_OUT’,‘FAN_AVG’
    • uniform:是否使用均匀或正态分布随机初始化
    • seed:一个Python整数。用于创建随机种子。看到“特遣部队。set_random_seed”行为
    • dtype:数据类型。只支持浮点类型

    返回值:

    • 生成单位方差张量的初始化器

    可能产生的异常:

    1. ValueError: if `dtype` is not a floating point type.
    2. TypeError: if `mode` is not in ['FAN_IN', 'FAN_OUT', 'FAN_AVG'].

  • 相关阅读:
    深入探究Python多进程编程:Multiprocessing模块基础与实战【第98篇—Multiprocessing模块】
    南科大计算机系:将开源和企业引入计算机课程教学
    Java语句
    Android 获取安装的app
    .net 温故知新【16】:Asp.Net Core WebAPI 筛选器
    c++进阶教程:我见过最好的c++教程
    使用 GitHub Copilot 进行 Prompt Engineering 的初学者指南(译)
    mysql拼接字符串函数
    P1278 单词游戏 简单搜索+玄学优化
    无锁队列Disruptor使用笔记
  • 原文地址:https://blog.csdn.net/weixin_36670529/article/details/99726741