tf.random_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None) x = tf.random.normal([2,784])
tf.random.truncated_normal()用法——截断正态分布 输出截断的正态分布的随机值。
tf.random.truncated_normal( shape, mean=0.0, stddev=1.0, dtype=tf.dtypes.float32, seed=None, name=None )shape: A 1-D integer Tensor or Python array. The shape of the output tensor. mean: A 0-D Tensor or Python value of type dtype. The mean of the truncated normal distribution.均值默认为0 stddev: A 0-D Tensor or Python value of type dtype. The standard deviation of the normal distribution, before truncation.截断前正态分布的标准偏差,默认为1.0 dtype: The type of the output. seed: A Python integer. Used to create a random seed for the distribution. Seetf.compat.v1.set_random_seed for behavior. name: A name for the operation (optional).
部分参数解释:
inputs:输入该网络层的数据
units:输出的维度大小,改变inputs的最后一维
activation:激活函数,即神经网络的非线性变化
use_bias:使用bias为True(默认使用),不用bias改成False即可,是否使用偏置项
trainable=True:表明该层的参数是否参与训练。如果为真则变量加入到图集合中
GraphKeys.TRAINABLE_VARIABLES (see tf.Variable)
在其他网站上看到的使用现象
dense1 = tf.layers.dense(inputs=pool3, units=1024, activation=tf.nn.relu,
kernel_regularizer=tf.contrib.layers.l2_regularizer(0.003))