numpy - Tensorflow 密集层操作

标签 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

最佳答案

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

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

关于numpy - Tensorflow 密集层操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45988484/

相关文章:

javascript - react 中的Tensorflow automl模型

python - 值错误 : None values not supported Keras Custom Loss Function in Tensorflow

tensorflow - 为什么深度学习模型没有与加州房价数据收敛?

python - 选择2个不同大小的numpy数组之间最接近的元素

tensorflow - 在 tf_agents 中使用 BatchedPyEnvironment

python - numpy 数组中维度的平均值

machine-learning - 机器学习模型如何加载到应用程序中?

image-processing - 将描述符与描述符数据库匹配

python - 如何解释 `scipy.stats.kstest` 和 `ks_2samp` 以评估 `fit` 的数据分布?

python - 将值分配给图像数组的随机 block 的有效方法?