tf.get_variable的初始化調(diào)用為:
tf.get_variable(name, shape=None, initializer=None, dtype=tf.float32, trainable=True, collections=None)
變量初始化的方法
tf.constant_initializer(const):常量初始化函數(shù)
tf.random_normal_initializer():正態(tài)分布初始化函數(shù)
tf.truncated_normal_initializer(mean = 0.0, stddev = 1.0, seed = None, dtype = dtypes.float32):截取的正態(tài)分布初始化函數(shù)
tf.random_uniform_initializer(minval = 0, maxval = None, seed = None, dtype = dtypes.float32):均勻分布初始化函數(shù)
tf.zeros_initializer():全0常量初始化函數(shù)
tf.ones_initializer():全1常量初始化函數(shù)
tf.uniform_unit_scaling_initializer(factor = 1.0, seed = None, dtype = dtypes.float32):均勻分布(不指定最小兢卵、最大值)侄刽,初始化函數(shù)
tf.variance_scaling_initializer(scale = 1.0, mode = "fan_in", distribution = "normal", seed = None, dtype = dtypes.float32):由mode確定是截取的正態(tài)分布,還是均勻分布初始化函數(shù)
tf.orthogonal_initializer():正交矩陣初始化函數(shù)
tf.glorot_uniform_initializer():由輸入單元節(jié)點(diǎn)數(shù)和輸出單元節(jié)點(diǎn)數(shù)確定的均勻分布初始化函數(shù)
tf.glorot_normal_initializer():由輸入單元節(jié)點(diǎn)數(shù)和輸出單元節(jié)點(diǎn)數(shù)確定的截取的正態(tài)分布初始化函數(shù)
基本的變量初始化為:
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):設(shè)置產(chǎn)生隨機(jī)數(shù)的種子