美文网首页tensorflow
tensorflow—变量初始化函数

tensorflow—变量初始化函数

作者: Persistently | 来源:发表于2017-07-27 20:04 被阅读1555次

    tf.get_variable的初始化调用为:
    tf.get_variable(name, shape=None, initializer=None, dtype=tf.float32, trainable=True, collections=None)

    变量初始化的方法

    tf.constant_initializer(const):常量初始化函数
    tf.random_normal_initializer():正态分布初始化函数
    tf.truncated_normal_initializer(mean = 0.0, stddev = 1.0, seed = None, dtype = dtypes.float32):截取的正态分布初始化函数
    tf.random_uniform_initializer(minval = 0, maxval = None, seed = None, dtype = dtypes.float32):均匀分布初始化函数
    tf.zeros_initializer():全0常量初始化函数
    tf.ones_initializer():全1常量初始化函数
    tf.uniform_unit_scaling_initializer(factor = 1.0, seed = None, dtype = dtypes.float32):均匀分布(不指定最小、最大值),初始化函数
    tf.variance_scaling_initializer(scale = 1.0, mode = "fan_in", distribution = "normal", seed = None, dtype = dtypes.float32):由mode确定是截取的正态分布,还是均匀分布初始化函数
    tf.orthogonal_initializer():正交矩阵初始化函数
    tf.glorot_uniform_initializer():由输入单元节点数和输出单元节点数确定的均匀分布初始化函数
    tf.glorot_normal_initializer():由输入单元节点数和输出单元节点数确定的截取的正态分布初始化函数

    基本的变量初始化为:

    tf.ones(shape, dtype = tf.float32, name = None)
    tf.zeros(shape, dtype = tf.float32, name = None)
    tf.ones_like(tensor, dtype = None, name = None)
    tf.zeros_like(tensor, dtype = None, name = None)
    tf.fill(dim, value, name = None)
    tf.constant(value, dtype = None, shape = None, name = None)
    tf.linspace(start, stop, num, name = None)
    tf.range(start, limit = None, delta = 1, name = None)
    tf.random_normal(shape, mean = 0.0, stddev = 1.0, dtype = tf.float32, seed = None, name = None)
    tf.truncated_normal(shape, mean = 0.0, stddev = 1.0, dtype = tf.float32, seed = None, name = None)
    tf.random_uniform(shape, minval = 0, maxval = None, dtype = tf.float32, seed = None, name = None)
    tf.random_shuffle(value, seed =None, name = None)
    tf.set_random_seed(seed):设置产生随机数的种子


    TensorFlow变量初始化
    TensorFlow

    相关文章

      网友评论

        本文标题:tensorflow—变量初始化函数

        本文链接:https://www.haomeiwen.com/subject/onrtlxtx.html