Tensorflow密集层操作

时间:2017-08-31 19:06:22

标签: numpy tensorflow neural-network tensor

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

1 个答案:

答案 0 :(得分:1)

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

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