1. keras.layers.Dense

(Fully Connected Neural NetWork),所实现的运算是output = activation(dot(input, kernel)+bias)

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

keras.layers.Dense(units,               // 该层的neuron的个数
           activation=None,          // 该层的激活函数。如果不指定该参数,将不会使用任何激活函数(即使用线性激活函数:a(x)=x)
           use_bias=True,            // 是否添加偏置项
           kernel_initializer='glorot_uniform',    // 权重初始化方法
           bias_initializer='zeros',         // 偏置值初始化方法
           kernel_regularizer=None,         // 权重正则化方化
           bias_regularizer=None,          // 偏置值正则化方法
           activity_regularizer=None,      // Output的正则化方法
           kernel_constraint=None,         // 权重变化限制函数
           bias_constraint=None)         // 偏置值变化限制函数

除了input layer须指定input_dim之外,所有hidden layer和ouput layer的input_dim默认都是上一层的output_dim。

 

在keras中,数据是以张量的形式表示的,张量的形状称之为shape,表示从最外层向量逐步到达最底层向量的降维解包过程。比如,一个一阶的张量[1,2,3]的shape是(3,);一个二阶的张量[[1,2,3],[4,5,6]]的shape是(2,3);一个三阶的张量[[[1],[2],[3]],[[4],[5],[6]]]的shape是(2,3,1)。

input_shape就是指输入张量的shape。例如,input_dim=784,说明输入是一个784维的向量,这相当于一个一阶的张量,它的shape就是(784,)。因此,input_shape=(784,)。

input_dim = input_shape(input_dim,)

input_dim, input_length = input_shape(input_length, input_dim)

 

REFERENCE:

https://blog.csdn.net/weixin_42499236/article/details/84624195

https://blog.csdn.net/gjq246/article/details/72638343/

https://blog.csdn.net/x_ym/article/details/77728732

https://www.cnblogs.com/yqtm/p/6924939.html

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄