如果深度学习模型的权重初始化得太小,那么信号将在每层间传递时逐渐缩小而难以产生作用。
如果权重初始化得太大,那信号将在每层间传递时逐渐放大并导致发散和失效
Xavier初始化器得作用,就是在初始化深度学习网络得时候让权重不大不小。
import numpy as np import sklearn.preprocessing as prep
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
def xavier_init(fan_in, fan_out, constant = 1):
low = -constant * np.sqrt(6.0 / (fan_in + fan_out))
high = constant * np.sqrt(6.0 / (fan_in + fan_out))
return tf.random_uniform((fan_in, fan_out), minval=low, maxval=high, dtype=tf.float32)
推导过程属于均匀分布的内容
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END