tf.layers.dense用法
2018年05月30日 19:09:58 o0haidee0o 阅读数:20426
dense:全连接层
相当于添加一个层,即初学的add_layer()函数
-
tf.layers.dense(
-
inputs,
-
units,
-
activation=None,
-
use_bias=True,
-
kernel_initializer=None,
-
bias_initializer=tf.zeros_initializer(),
-
kernel_regularizer=None,
-
bias_regularizer=None,
-
activity_regularizer=None,
-
kernel_constraint=None,
-
bias_constraint=None,
-
trainable=True,
-
name=None,
-
reuse=None
-
)
其中:
inputs: 该层的输入
units: 输出的大小(维数),整数或long
activation: 使用什么激活函数(神经网络的非线性层),默认为None,不使用激活函数
use_bias: 使用bias为True(默认使用),不用bias改成False即可
-
kernel_initializer
: Initializer function for the weight matrix. IfNone
(default), weights are initialized using the default initializer used bytf.get_variable
. -
bias_initializer
: Initializer function for the bias. -
kernel_regularizer
: Regularizer function for the weight matrix. -
bias_regularizer
: Regularizer function for the bias. -
activity_regularizer
: Regularizer function for the output. -
kernel_constraint
: An optional projection function to be applied to the kernel after being updated by anOptimizer
(e.g. used to implement norm constraints or value constraints for layer weights). The function must take as input the unprojected variable and must return the projected variable (which must have the same shape). Constraints are not safe to use when doing asynchronous distributed training. -
bias_constraint
: An optional projection function to be applied to the bias after being updated by anOptimizer
. -
trainable
: Boolean, ifTrue
also add variables to the graph collectionGraphKeys.TRAINABLE_VARIABLES
(seetf.Variable
). -
name
: String, the name of the layer. -
reuse
: Boolean, whether to reuse the weights of a previous layer by the same name.
(后面懒得翻译了,有空再说吧,[微笑脸])