无法理解keras密集层的输出

时间:2019-04-01 06:32:15

标签: python tensorflow keras

我正在测试keras层。我建立了一个简单的密集层,其输入形状为(10,2),所有值均等于1。并且我使用zero_initial_state来设置初始层权重。但是,我无法理解密集层的输出,因为它可能用sth计算最终输出。未知。我的代码是:

batch_size = 10
time_steps = 30
label_num = 2.
units = 5

batch_data = tf.ones((batch_size, label_num))

dense_layer = Dense(units)
output = dense_layer(batch_data)
with tf.Session() as sess:
  init = tf.global_variables_initializer()
  sess.run(init)
  print('__________________output_____________________')
  print(sess.run(output))

我打印初始内核并进行偏向:

____________________self.kernel____________________

[[-0.6072792   0.87520194 -0.5916964  -0.28233814  0.37042332]
 [ 0.24503589 -0.8950937  -0.7122175   0.67322683  0.9035703 ]]

____________________self.bias____________________

[0. 0. 0. 0. 0.]

我认为最终输出应该是:

[[-0.3622433  -0.01989174 -1.3039138   0.3908887   1.2739936 ]
 [-0.3622433  -0.01989174 -1.3039138   0.3908887   1.2739936 ]
 [-0.3622433  -0.01989174 -1.3039138   0.3908887   1.2739936 ]
 [-0.3622433  -0.01989174 -1.3039138   0.3908887   1.2739936 ]
 ....

但是,最终输出是:

[[-0.25280607  1.0728977  -0.6096982   1.1957564   0.82103825]
 [-0.25280607  1.0728977  -0.6096982   1.1957564   0.82103825]
 [-0.25280607  1.0728977  -0.6096982   1.1957564   0.82103825]

激活为无。为什么角膜密集层的输出是这个?

0 个答案:

没有答案