Tensorflow 密集层操作

Tensorflow dense layer operation

a = tf.random_uniform([5, 3, 5])
b = tf.random_uniform([5, 1, 6])

tiled_b = tf.tile(b, [1, 3, 1])
c = tf.concat([a, tiled_b], 2)
d = tf.layers.dense(c, 10, activation=tf.nn.relu)

这里的输出形状原来是5x3x10。输入形状是 5x3x11。我看过这个操作的源代码,发现权重矩阵的形状是11x10。我也明白,操作类似于res = np.tensordot(input,weights,axes=([2],[0]))。我不明白这是怎么发生的。如何在神经网络中可视化此操作?因为,密集层只是一个有 10 个神经元的单层,权重矩阵怎么可能是 11x10?

对于密集层,每个输入通道都连接到具有权重的每个输出神经元。所以这里 input_channel=11ouput_channel=10,所以权重数 11x10.

# input 5x3x11, here last dimension is the input channel
dense_layer_weight_shape = [input_channel, output_channel]