通常NN层的描述如下:
units 的值:
数据如下:
inputs : shape=(1, 5)
[[1. 2. 3. 4. 5.]]
kernel (weights): shape=(5, 10)
[[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]]
bias : shape=(10,)
[0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]
units (outputs): shape=(1, 10)
[[ 15., 31., 47., 63., 79., 95., 111., 127., 143., 159.]]
keras层的定义:
tf.keras.layers.Dense(
units, # 也就是输出节点数
kernel_initializer, # 初始化weights矩阵,尺寸:[inputs, units]
bias_initializer, # 初始化bias数组, 尺寸:[units]
inputs_shape=[batches, featues], # 还是会根据实际输入改变
)
keras层的数据对应方式 (n=5):