【问题标题】:Tensorflow dense layer operationTensorFlow 密集层操作
【发布时间】:2018-02-09 19:47:56
【问题描述】:
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]))。我不明白这是怎么回事。如何在神经网络中可视化此操作?既然dense layer只是单层有10个神经元,那么权重矩阵怎么可能是11x10

【问题讨论】:

    标签: numpy tensorflow neural-network tensor


    【解决方案1】:

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

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

    【讨论】:

    • 每个神经元如何连接到输入通道?您是说每个神经元都由5x3 矩阵共享吗?如果是这样,正在发生的操作是什么?
    • 每个5x3 组都包含10 输出神经元。在输入中,有5x311 输入神经元。因此,在每个5x3 组中,11 的集合乘以矩阵得到10 的集合。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    • 2019-12-24
    • 2017-07-31
    • 2023-03-05
    • 1970-01-01
    相关资源
    最近更新 更多